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:
Claudia Meadows 2024-09-24 22:11:10 -07:00
parent 08f5ccfeda
commit 542946fd74
No known key found for this signature in database
GPG key ID: C86B594396786760
5 changed files with 21 additions and 37 deletions

View file

@ -1,4 +1,4 @@
name: Warn on pushing to `release` name: Warn on opening a PR to `release`
on: on:
pull_request_target: pull_request_target:
types: [opened] types: [opened]

View file

@ -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

View file

@ -1,12 +1,11 @@
name: merge name: Create release when pushing to `release`
on: on:
push: push:
branches: [ release ] branches: [release]
workflow_dispatch: workflow_dispatch:
concurrency: prr:deploy concurrency: merge-release
jobs: jobs:
merge: 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 - run: npx pr-release merge --target release --source main --commit --force --clean --changelog ./docs/recent-changes.md --compact --minimize-semver-change
env: env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- run: bash scripts/set-versioned-branch.sh release
# The following will publish the release to npm # The following will publish the release to npm
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
name: Setup NPM Auth name: Setup NPM Auth

View file

@ -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 - run: npx pr-release rollback --verbose --target release --source main --verbose --ignore 'package*' --ignore docs/changelog.md --ignore docs/recent-changes.md
env: env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- run: bash scripts/set-versioned-branch.sh release

View 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}"