88 ci :
99 uses : ./.github/workflows/ci.yml
1010 cd :
11+ needs :
12+ - ci
1113 runs-on : ubuntu-latest
1214 steps :
13- - uses : actions/checkout@v4
14- - uses : actions/setup-node@v4
15- with :
16- cache : ' npm'
17- node-version-file : ' .nvmrc'
18- registry-url : ' https://registry.npmjs.org'
15+ - name : Debug info
16+ run : |
17+ cat <<EOF
18+ Release tag name: ${{ github.event.release.tag_name }}
19+ Release target commit-ish: ${{ github.event.release.target_commitish }}
20+ EOF
21+
22+ - name : Determine NPM tag
23+ id : npm_tag
24+ shell : bash
25+ run : |
26+ case ${{ github.event.release.target_commitish }} in
27+ develop | main | master)
28+ if [[ ${{ github.event.release.prerelease }} == true ]]; then
29+ npm_tag=beta
30+ else
31+ npm_tag=latest
32+ fi
33+ ;;
34+ *)
35+ # use the branch name
36+ npm_tag="${{ github.event.release.target_commitish }}"
37+ ;;
38+ esac
39+ echo "Determined NPM tag: [$npm_tag]"
40+ echo "npm_tag=${npm_tag}" >> "$GITHUB_OUTPUT"
41+ - name : Check NPM tag
42+ run : |
43+ if [ -z "${{ steps.npm_tag.outputs.npm_tag }}" ]; then
44+ echo "Refusing to publish with empty NPM tag."
45+ exit 1
46+ fi
1947
2048 - name : Config GitHub user
2149 shell : bash
2250 run : |
2351 git config --global user.name 'GitHub Actions'
2452 git config --global user.email 'github-actions@localhost'
2553
54+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
55+ with :
56+ token : ${{ secrets.PAT_RELEASE_PUSH }} # persists the token for pushing to the repo later
57+
58+ - uses : actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
59+ with :
60+ cache : ' npm'
61+ node-version-file : ' .nvmrc'
62+ registry-url : ' https://registry.npmjs.org'
63+
64+ - uses : ./.github/actions/install-dependencies
65+
2666 - name : Update the version in the package files
2767 shell : bash
2868 run : |
2969 GIT_TAG="${{github.event.release.tag_name}}"
3070 NEW_VERSION="${GIT_TAG/v/}"
3171
32- bash ./scripts/update-dependencies-with-tag-versions.sh "$NEW_VERSION"
33- git add package* && git commit -m "Release $NEW_VERSION"
34-
35- - uses : ./.github/actions/install-dependencies
72+ npm version "$NEW_VERSION" --no-git-tag-version
73+ git add package* && git commit -m "chore(release): $NEW_VERSION [skip ci]"
3674
3775 - name : Build packages
3876 run : npm run build
3977
4078 - name : Publish scratch-svg-renderer
41- run : npm publish --access=public --workspace=@scratch/scratch-svg-renderer
79+ run : npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" -- workspace=@scratch/scratch-svg-renderer
4280 env :
4381 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
4482
4583 - name : Publish scratch-render
46- run : npm publish --access=public --workspace=@scratch/scratch-render
84+ run : npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" -- workspace=@scratch/scratch-render
4785 env :
4886 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
4987
5088 - name : Publish scratch-vm
51- run : npm publish --access=public --workspace=@scratch/scratch-vm
89+ run : npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" -- workspace=@scratch/scratch-vm
5290 env :
5391 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
5492
5593 - name : Publish scratch-gui
56- run : npm publish --access=public --workspace=@scratch/scratch-gui
94+ run : npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" -- workspace=@scratch/scratch-gui
5795 env :
5896 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
5997
@@ -80,35 +118,33 @@ jobs:
80118 git push -f origin "refs/tags/${{github.event.release.tag_name}}"
81119
82120 - name : Deploy scratch-svg-renderer to GitHub Pages
83- uses : peaceiris/actions-gh-pages@v4
121+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
84122 with :
85123 github_token : ${{ secrets.GITHUB_TOKEN }}
86124 publish_dir : ./packages/scratch-svg-renderer/playground
87125 destination_dir : scratch-svg-renderer
88126 full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
89127
90128 - name : Deploy scratch-render to GitHub Pages
91- uses : peaceiris/actions-gh-pages@v4
129+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
92130 with :
93131 github_token : ${{ secrets.GITHUB_TOKEN }}
94132 publish_dir : ./packages/scratch-render/playground
95133 destination_dir : scratch-render
96134 full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
97135
98136 - name : Deploy scratch-vm to GitHub Pages
99- uses : peaceiris/actions-gh-pages@v4
137+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
100138 with :
101139 github_token : ${{ secrets.GITHUB_TOKEN }}
102140 publish_dir : ./packages/scratch-vm/playground
103141 destination_dir : scratch-vm
104142 full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
105143
106144 - name : Deploy scratch-gui to GitHub Pages
107- uses : peaceiris/actions-gh-pages@v4
145+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
108146 with :
109147 github_token : ${{ secrets.GITHUB_TOKEN }}
110148 publish_dir : ./packages/scratch-gui/build
111149 destination_dir : scratch-gui
112150 full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
113- needs :
114- - ci
0 commit comments