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"
72+ npm version "$NEW_VERSION" --no-git-tag-version
73+ git add package* && git commit -m "chore(release): $NEW_VERSION [skip ci] "
3474
75+ # Install dependencies after the version update so that
76+ # the build outputs refer to the newest version of inner packages
3577 - uses : ./.github/actions/install-dependencies
3678
3779 - name : Build packages
3880 run : npm run build
3981
4082 - name : Publish scratch-svg-renderer
41- run : npm publish --access=public --workspace=@scratch/scratch-svg-renderer
83+ run : npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" -- workspace=@scratch/scratch-svg-renderer
4284 env :
4385 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
4486
4587 - name : Publish scratch-render
46- run : npm publish --access=public --workspace=@scratch/scratch-render
88+ run : npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" -- workspace=@scratch/scratch-render
4789 env :
4890 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
4991
5092 - name : Publish scratch-vm
51- run : npm publish --access=public --workspace=@scratch/scratch-vm
93+ run : npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" -- workspace=@scratch/scratch-vm
5294 env :
5395 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
5496
5597 - name : Publish scratch-gui
56- run : npm publish --access=public --workspace=@scratch/scratch-gui
98+ run : npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" -- workspace=@scratch/scratch-gui
5799 env :
58100 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
59101
@@ -80,35 +122,33 @@ jobs:
80122 git push -f origin "refs/tags/${{github.event.release.tag_name}}"
81123
82124 - name : Deploy scratch-svg-renderer to GitHub Pages
83- uses : peaceiris/actions-gh-pages@v4
125+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
84126 with :
85127 github_token : ${{ secrets.GITHUB_TOKEN }}
86128 publish_dir : ./packages/scratch-svg-renderer/playground
87129 destination_dir : scratch-svg-renderer
88130 full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
89131
90132 - name : Deploy scratch-render to GitHub Pages
91- uses : peaceiris/actions-gh-pages@v4
133+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
92134 with :
93135 github_token : ${{ secrets.GITHUB_TOKEN }}
94136 publish_dir : ./packages/scratch-render/playground
95137 destination_dir : scratch-render
96138 full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
97139
98140 - name : Deploy scratch-vm to GitHub Pages
99- uses : peaceiris/actions-gh-pages@v4
141+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
100142 with :
101143 github_token : ${{ secrets.GITHUB_TOKEN }}
102144 publish_dir : ./packages/scratch-vm/playground
103145 destination_dir : scratch-vm
104146 full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
105147
106148 - name : Deploy scratch-gui to GitHub Pages
107- uses : peaceiris/actions-gh-pages@v4
149+ uses : peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
108150 with :
109151 github_token : ${{ secrets.GITHUB_TOKEN }}
110152 publish_dir : ./packages/scratch-gui/build
111153 destination_dir : scratch-gui
112154 full_commit_message : " Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
113- needs :
114- - ci
0 commit comments