Merge pull request #127 from michaelkamphausen/feature/remove-device-… #65
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 | |
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/package-json-updated-action@v1.0.5 | |
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: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 8 | |
run_install: false | |
- uses: actions/checkout@v4 | |
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 github-actions@github.com | |
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@v2 | |
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 }} |