Skip to content

Commit ed3ba88

Browse files
committed
ci: determine tag for "npm publish" from branch name
1 parent 9030d5c commit ed3ba88

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/publish.yml

+35
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ jobs:
1010
cd:
1111
runs-on: ubuntu-latest
1212
steps:
13+
- name: Debug info
14+
run: |
15+
cat <<EOF
16+
Release tag name: ${{ github.event.release.tag_name }}
17+
Release target commit-ish: ${{ github.event.release.target_commitish }}
18+
EOF
19+
1320
- name: Config GitHub user
1421
shell: bash
1522
run: |
@@ -40,6 +47,34 @@ jobs:
4047
- name: Build packages
4148
run: npm run build
4249

50+
- name: Determine NPM tag
51+
id: npm_tag
52+
shell: bash
53+
run: |
54+
case ${{ github.event.release.target_commitish }} in
55+
develop)
56+
main)
57+
master)
58+
if [[ ${{ github.event.release.prerelease }} == true ]]; then
59+
npm_tag=beta
60+
else
61+
npm_tag=latest
62+
fi
63+
;;
64+
*)
65+
# use the branch name
66+
npm_tag="${{ github.event.release.target_commitish }}"
67+
;;
68+
esac
69+
echo "Determined NPM tag: [$npm_tag]"
70+
echo "npm_tag=${npm_tag}" >> "$GITHUB_OUTPUT"
71+
- name: Check NPM tag
72+
run: |
73+
if [ -n "${{ steps.npm_tag.outputs.npm_tag }}" ]; then
74+
echo "Refusing to publish with empty NPM tag."
75+
exit 1
76+
fi
77+
4378
# - name: Publish scratch-svg-renderer
4479
# run: npm publish --access=public --workspace=@scratch/scratch-svg-renderer
4580
# env:

0 commit comments

Comments
 (0)