From 0b4cdb2fb297064bfea53c7225fa1dc3a84132e5 Mon Sep 17 00:00:00 2001 From: zgq Date: Mon, 21 Sep 2026 14:39:30 +0800 Subject: [PATCH] ci(release): publish from a tag push instead of a manual dispatch A version release is one event: the tag, the five platform builds, the JDK worker, the GitHub Release and the three npm packages. Publishing required a tag push plus `gh workflow run packages.yml --ref vX -f publish=true`, so the second step could be forgotten or run for another ref. Trigger the workflow on `v*` tag pushes as well and let the publish steps run for `github.event_name == 'push'`, keeping `workflow_dispatch` for a dry build without publishing. The existing assertions still gate the release: the tag name must equal the version in the three `package.json` files, the tag must be annotated and point at the checked-out commit, and CI must have succeeded on that commit. A tag push can start while the CI run for the same commit is still going, which previously failed the release immediately. The publish step now waits up to 20 minutes for that CI run and stops early when it has already failed. --- .github/workflows/packages.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 2e403ee..16776b1 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -1,5 +1,7 @@ name: Packages on: + push: + tags: ["v*"] workflow_dispatch: inputs: publish: @@ -104,11 +106,20 @@ jobs: name: release-bundle path: dist/ - name: Publish release - if: inputs.publish + if: github.event_name == 'push' || inputs.publish env: GH_TOKEN: ${{ github.token }} run: | - passed=$(gh run list --workflow ci.yml --commit "$GITHUB_SHA" --status success --json databaseId --jq 'length') + # A tag push can start before the CI run for the same commit has finished, so wait for it + # (up to 20 minutes) and stop early when it already failed. + passed=0 + for _ in $(seq 1 40); do + passed=$(gh run list --workflow ci.yml --commit "$GITHUB_SHA" --status success --json databaseId --jq 'length') + if [ "$passed" -gt 0 ]; then break; fi + failed=$(gh run list --workflow ci.yml --commit "$GITHUB_SHA" --status failure --json databaseId --jq 'length') + if [ "$failed" -gt 0 ]; then break; fi + sleep 30 + done test "$passed" -gt 0 # checkout's shallow SHA fetch creates a local lightweight tag; retrieve the actual tag object. git fetch --force origin refs/tags/v0.1.10:refs/tags/v0.1.10 @@ -119,7 +130,7 @@ jobs: gh release edit v0.1.10 --draft=false --latest npm: needs: [assemble] - if: inputs.publish + if: github.event_name == 'push' || inputs.publish runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262