Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/publish-approved-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish approved releases
# The release workflow stages each version on npm and creates a draft GitHub
# release. A staged version can't be installed until a maintainer runs
# `npm stage approve`. npm doesn't notify GitHub when that happens, so this
# checks npm on a schedule and publishes each draft release whose version is
# now on npm. Run it by hand to publish right after approving:
# gh workflow run publish-approved-releases.yml
# A rejected stage never reaches npm, so its draft stays a draft. Delete that
# draft and its tag by hand.
"on":
schedule:
- cron: "*/15 * * * *"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: publish-approved-releases
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
sparse-checkout: package.json
sparse-checkout-cone-mode: false
- name: Publish drafts whose version is on npm
env:
GH_TOKEN: ${{ github.token }}
run: |
package=$(jq -r .name package.json)
# Oldest first, so the newest release ends up marked "Latest".
gh release list --limit 50 --json tagName,isDraft \
--jq '[.[] | select(.isDraft)] | reverse | .[].tagName' |
while read -r tag; do
version=${tag#v}
if [ "$(npm view "$package@$version" version 2>/dev/null)" = "$version" ]; then
echo "$package@$version is on npm: publishing release $tag"
gh release edit "$tag" --draft=false
else
echo "$package@$version is not on npm yet: leaving $tag as a draft"
fi
done
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ npm stage download <stage-id> # optional: inspect the tarball
npm stage approve <stage-id>
```

Then publish the draft release at
https://github.com/commitizen/cz-cli/releases.
You don't need to publish the draft GitHub release yourself. The "Publish
approved releases" workflow checks npm every 15 minutes and publishes the draft
once its version is on npm. To publish it right away, run
`gh workflow run publish-approved-releases.yml -R commitizen/cz-cli`.

To abandon a staged version instead, run `npm stage reject <stage-id>`,
delete the draft release, and delete its tag (`git push origin :refs/tags/vX.Y.Z`)
Expand Down
Loading