Skip to content

Commit

Permalink
Update publish CI
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Dec 11, 2024
1 parent b2d953f commit a0cf114
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,28 @@ jobs:
registry-url: https://registry.npmjs.org/

- run: |
VERSION=${GITHUB_REF/refs\/tags\//}
TAG='latest'
if [[ $VERSION =~ 'alpha' || $VERSION =~ 'beta' || $VERSION =~ 'rc' ]]; then
TAG='next'
fi
npm publish --tag $TAG
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NPM_TAG='latest'
IS_PRERELEASE=false
# @see https://github.com/actions/create-release/issues/38#issuecomment-715327220
# @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
- name: Prepare the changelog from the tag message
id: prepare_changelog
run: |
PRERELEASE=false
# Check release type
if [[ $GITHUB_REF_NAME =~ 'alpha' || $GITHUB_REF_NAME =~ 'beta' || $GITHUB_REF_NAME =~ 'rc' ]]; then
echo "This is a prerelease."
PRERELEASE=true
NPM_TAG='next'
IS_PRERELEASE=true
fi
echo "is_prerelease=$PRERELEASE" >> $GITHUB_ENV
# @see https://github.com/actions/create-release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
echo "NPM_TAG=$NPM_TAG" >> $GITHUB_ENV
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV
- uses: JS-DevTools/npm-publish@v3
with:
provenance: true
package: .
tag: ${{ env.NPM_TAG }}
token: ${{ secrets.NPM_TOKEN }}

- uses: ncipollo/release-action@v1
with:
tag_name: ${{ github.ref }}
release_name: v${{ github.ref_name }}
body: Please refer to [CHANGELOG.md](https://github.com/studiometa/prettier-formatter-gitlab/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
tag: ${{ github.ref }}
name: v${{ github.ref_name }}
body: Please refer to [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
draft: false
prerelease: ${{ env.is_prerelease }}
prerelease: ${{ env.IS_PRERELEASE }}

0 comments on commit a0cf114

Please sign in to comment.