Skip to content

bump version for release #55

bump version for release

bump version for release #55

Workflow file for this run

name: Release
on:
push:
branches:
- main
permissions:
contents: write
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 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: pnpm/action-setup@v2
with:
version: 8
run_install: false
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Install Dependencies
id: deps
run: |
pnpm install
- name: Build Release
id: build_release
run: |
pnpm build
- name: Sync README
run: |
git config user.name github-actions
git config user.email [email protected]
if ! cmp -s ./README.md ./packages/auth/README.md; then
if git diff --quiet HEAD ./README.md; then
cp ./packages/auth/README.md ./README.md
else
cp ./README.md ./packages/auth/README.md
fi
git add .
git commit -m "Sync README.md"
git push origin ${{ github.ref }}
fi
- name: Run Tests
id: tests
run: |
pnpm test
- name: Publish Release
if: steps.tests.outcome == 'success'
run: |
if [ "$NODE_AUTH_TOKEN" = "" ]; then
echo "You need a NPM_TOKEN secret in order to publish."
false
fi
echo //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} > .npmrc
EXTRA_ARGS=""
if [[ $VERSION == *"alpha."* ]] || [[ $VERSION == *"beta."* ]] || [[ $VERSION == *"rc."* ]]; then
echo "Is pre-release version"
EXTRA_ARGS="$EXTRA_ARGS --dist-tag next"
fi
npx lerna publish ${VERSION} --yes --force-publish $EXTRA_ARGS
echo 馃帀 Published to NPM https://www.npmjs.com/package/@localfirst/auth/v/${VERSION}
env:
VERSION: ${{ needs.check_if_version_upgraded.outputs.version }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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: main
generate_release_notes: true
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}