Skip to content

Commit c34518b

Browse files
committed
ci: determine tag for "npm publish" from branch name
1 parent a233860 commit c34518b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,39 @@ jobs:
1212
# - ci
1313
runs-on: ubuntu-latest
1414
steps:
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
47+
1548
- name: Config GitHub user
1649
shell: bash
1750
run: |

0 commit comments

Comments
 (0)