v1.2.0-alpha.0 #286
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/[email protected] | |
id: version-updated | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish-docs: | |
name: Publish Docs | |
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 and Build | |
run: | | |
pnpm install | |
pnpm build | |
- name: Build docs | |
run: npx typedoc | |
- name: Deploy 🚀 | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: docs | |
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: 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 | |
git config user.name github-actions | |
git config user.email [email protected] | |
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 | |
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 }} |