Skip to content

Commit 97bf00d

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

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/publish.yml

+33
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,39 @@ 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+
20+
- name: Determine NPM tag
21+
id: npm_tag
22+
shell: bash
23+
run: |
24+
case ${{ github.event.release.target_commitish }} in
25+
develop | main | master)
26+
if [[ ${{ github.event.release.prerelease }} == true ]]; then
27+
npm_tag=beta
28+
else
29+
npm_tag=latest
30+
fi
31+
;;
32+
*)
33+
# use the branch name
34+
npm_tag="${{ github.event.release.target_commitish }}"
35+
;;
36+
esac
37+
echo "Determined NPM tag: [$npm_tag]"
38+
echo "npm_tag=${npm_tag}" >> "$GITHUB_OUTPUT"
39+
- name: Check NPM tag
40+
run: |
41+
if [ -n "${{ steps.npm_tag.outputs.npm_tag }}" ]; then
42+
echo "Refusing to publish with empty NPM tag."
43+
exit 1
44+
fi
45+
1346
- name: Config GitHub user
1447
shell: bash
1548
run: |

0 commit comments

Comments
 (0)