11name : Package Release
22
33on :
4- workflow_run :
5- workflows :
6- - CI Validation
4+ push :
75 branches :
86 - main
97 - next
10- types :
11- - completed
128
139env :
1410 GH_PACKAGES_TOKEN : ${{ secrets.GH_PACKAGES_TOKEN }}
@@ -33,12 +29,17 @@ concurrency:
3329 cancel-in-progress : false
3430
3531jobs :
32+ ci-validation :
33+ name : CI Validation
34+ uses : ./.github/workflows/check-ci-validation.yml
35+ secrets : inherit
36+
3637 release-and-publish :
3738 name : Release & Publish
3839 runs-on : ubuntu-latest
3940 timeout-minutes : 60
4041
41- if : github.event.workflow_run.conclusion == 'success'
42+ needs : ci-validation
4243
4344 steps :
4445 - name : Checkout repository
4748 token : ${{ secrets.GH_REPO_TOKEN }}
4849 fetch-depth : 0
4950
50- - name : Checkout target branch
51- run : |
52- git checkout ${{ github.event.workflow_run.head_branch }}
53-
5451 - name : Prepare Node.js environment
5552 uses : actions/setup-node@v6
5653 with :
8077 # Packages registry, providing a predictable release workflow for both registries.
8178 - name : Publish package to public npm registry
8279 id : semantic-release
83- # `GITHUB_REF` is overridden at the shell level because in `workflow_run` events
84- # it always points to the default branch, not the branch that triggered the run.
85- # The step-level `env:` block cannot override `GITHUB_*` variables in Actions.
8680 run : |
87- GITHUB_REF=${{ github.event.workflow_run.head_branch }} npx semantic-release
81+ npx semantic-release
8882 env :
8983 GITHUB_TOKEN : ${{ secrets.GH_REPO_TOKEN }}
9084 GIT_AUTHOR_EMAIL :
[email protected] @@ -110,7 +104,7 @@ jobs:
110104 if : ${{ steps.semantic-release.outputs.package-published == 'true' }}
111105 id : dist-tag
112106 run : |
113- if [[ "${{ github.event.workflow_run.head_branch }}" == "next" ]]; then
107+ if [[ "${{ github.ref_name }}" == "next" ]]; then
114108 echo "tag=next" >> $GITHUB_OUTPUT
115109 else
116110 echo "tag=latest" >> $GITHUB_OUTPUT
0 commit comments