Skip to content

Commit 33afecd

Browse files
committed
Update release action
1 parent f054de1 commit 33afecd

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

.github/workflows/npm-publish.yml

+35-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,48 @@ on:
66
- '*.*.*'
77

88
jobs:
9-
publish:
10-
runs-on: ubuntu-latest
9+
release:
10+
runs-on: macos-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: JS-DevTools/npm-publish@v3
13+
- uses: actions/setup-node@v4
1414
with:
15-
token: ${{ secrets.NPM_TOKEN }}
16-
- uses: actions/create-release@v1
15+
node-version: 20
16+
cache: npm
17+
registry-url: https://registry.npmjs.org/
18+
19+
- run: |
20+
VERSION=${GITHUB_REF/refs\/tags\//}
21+
TAG='latest'
22+
if [[ $VERSION =~ 'alpha' || $VERSION =~ 'beta' || $VERSION =~ 'rc' ]]; then
23+
TAG='next'
24+
fi
25+
npm publish --tag $TAG
26+
env:
27+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
28+
29+
# @see https://github.com/actions/create-release/issues/38#issuecomment-715327220
30+
# @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
31+
- name: Prepare the changelog from the tag message
32+
id: prepare_changelog
33+
run: |
34+
PRERELEASE=false
35+
# Check release type
36+
if [[ $GITHUB_REF_NAME =~ 'alpha' || $GITHUB_REF_NAME =~ 'beta' || $GITHUB_REF_NAME =~ 'rc' ]]; then
37+
echo "This is a prerelease."
38+
PRERELEASE=true
39+
fi
40+
echo "is_prerelease=$PRERELEASE" >> $GITHUB_ENV
41+
42+
# @see https://github.com/actions/create-release
43+
- name: Create Release
44+
id: create_release
45+
uses: actions/create-release@v1
1746
env:
1847
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1948
with:
2049
tag_name: ${{ github.ref }}
2150
release_name: v${{ github.ref_name }}
2251
body: Please refer to [CHANGELOG.md](https://github.com/studiometa/prettier-formatter-gitlab/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
2352
draft: false
53+
prerelease: ${{ env.is_prerelease }}

0 commit comments

Comments
 (0)