Fix and clarify workflow logic, add branch versioning
- `pr.yml` should've been deleted a long time ago. Its functionality was already elsewhere, and that's since been folded into `test.yml`. - I added automatic `release-v*` and `main-v*` versioning. - Renamed `merge.yml` to `push-release.yml` and `push-main.yml` to `pr-create-release.yml` so it's clearer what they're actually listening to. I also modified their display names.
This commit is contained in:
parent
08f5ccfeda
commit
542946fd74
5 changed files with 21 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
|||
name: Warn on pushing to `release`
|
||||
name: Warn on opening a PR to `release`
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened]
|
||||
31
.github/workflows/pr.yml
vendored
31
.github/workflows/pr.yml
vendored
|
|
@ -1,31 +0,0 @@
|
|||
name: pr
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency: prr:pre-release
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- run: npx pr-release pr --verbose --target release --source main --compact --verbose --minimize-semver-change
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
# The following will publish a prerelease to npm
|
||||
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
|
||||
name: Setup NPM Auth
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
- run: npx pr-release infer-prerelease --preid=next --target release --source main --verbose --publish --minimize-semver-change
|
||||
name: Publish
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
name: merge
|
||||
name: Create release when pushing to `release`
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ release ]
|
||||
|
||||
branches: [release]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency: prr:deploy
|
||||
concurrency: merge-release
|
||||
|
||||
jobs:
|
||||
merge:
|
||||
|
|
@ -24,7 +23,7 @@ jobs:
|
|||
- run: npx pr-release merge --target release --source main --commit --force --clean --changelog ./docs/recent-changes.md --compact --minimize-semver-change
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- run: bash scripts/set-versioned-branch.sh release
|
||||
# The following will publish the release to npm
|
||||
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
|
||||
name: Setup NPM Auth
|
||||
1
.github/workflows/rollback.yml
vendored
1
.github/workflows/rollback.yml
vendored
|
|
@ -19,3 +19,4 @@ jobs:
|
|||
- run: npx pr-release rollback --verbose --target release --source main --verbose --ignore 'package*' --ignore docs/changelog.md --ignore docs/recent-changes.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
- run: bash scripts/set-versioned-branch.sh release
|
||||
|
|
|
|||
15
scripts/set-versioned-branch.sh
Normal file
15
scripts/set-versioned-branch.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
base="$1"
|
||||
|
||||
if [[ -z "$base" ]]; then
|
||||
echo '::error::Base branch is missing. Invoke as `bash scripts/set-versioned-branch.sh BASE' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
major=$(node -pe 'require("./package.json").version.replace(/\..*$/,"")')
|
||||
# Can't do a force push due to branch protection rules.
|
||||
git checkout "${base}"
|
||||
git checkout -B "${base}-v${major}"
|
||||
git push origin "${base}-v${major}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue