Release v0.12.2 #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
- next | |
jobs: | |
check_if_version_upgraded: | |
name: Check if package version has been upgraded | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version-updated.outputs.current-package-version }} | |
has_updated: ${{ steps.version-updated.outputs.has-updated }} | |
steps: | |
- uses: JiPaix/[email protected] | |
id: version-updated | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish-js: | |
name: Publish JS package | |
runs-on: ubuntu-latest | |
needs: | |
- check_if_version_upgraded | |
# We create release only if the version in the package.json has been upgraded | |
if: | | |
needs.check_if_version_upgraded.outputs.has_updated == 'true' | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18.x" | |
registry-url: "https://registry.npmjs.org" | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref }} | |
- name: run tests | |
id: tests | |
run: | | |
if [ "$BRANCH" = "next" ]; then | |
echo "Installing dependencies for next branch" | |
npm ci --force | |
else | |
npm ci | |
fi | |
npx vitest run | |
env: | |
BRANCH: ${{ github.ref_name }} | |
- name: Build Release | |
id: build_release | |
run: | | |
npm run build | |
- name: Create npm release | |
if: steps.tests.outcome == 'success' | |
run: | | |
if [ "$(npm . version)" = "$VERSION" ]; then | |
echo "This version is already published" | |
exit 0 | |
fi | |
EXTRA_ARGS="--access public" | |
if [[ $VERSION == *"alpha."* ]] || [[ $VERSION == *"beta."* ]] || [[ $VERSION == *"rc."* ]]; then | |
echo "Is pre-release version" | |
EXTRA_ARGS="$EXTRA_ARGS --tag next" | |
fi | |
if [ "$NODE_AUTH_TOKEN" = "" ]; then | |
echo "Can't publish on NPM, You need a NPM_TOKEN secret." | |
false | |
fi | |
npm publish $EXTRA_ARGS | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
VERSION: ${{ needs.check_if_version_upgraded.outputs.version }} | |
- name: Tag release | |
if: steps.tests.outcome == 'success' | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: v${{ needs.check_if_version_upgraded.outputs.version }} | |
tag_name: v${{ needs.check_if_version_upgraded.outputs.version }} | |
target_commitish: ${{ github.ref_name }} | |
generate_release_notes: true | |
draft: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |