Release Library #106
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 Library | |
# Job will only run on push to the main branch after the test job has passed | |
on: | |
workflow_run: | |
workflows: [ "Test Lib-Demo" ] | |
types: [ completed ] | |
workflow_dispatch: | |
inputs: { } | |
concurrency: | |
group: 'release-library' | |
cancel-in-progress: false | |
env: | |
ARTIFACT_NAME: "build-lib-artifact" | |
jobs: | |
build: | |
if: | | |
github.ref == 'refs/heads/main' && | |
github.event.repository.fork == false && | |
github.actor != 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
timeout-minutes: 2 | |
environment: FSI_DEP_NodeJs | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Bun - Version ${{ vars.BUN_VERSION }} | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: ${{ vars.BUN_VERSION }} | |
- name: Install dependencies | |
run: bun install | |
- name: Build library | |
run: | | |
bun run build:lib | |
bun run postBuild:lib | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ vars.DEMO_PATH }} | |
if-no-files-found: error | |
release: # This job will publish the library using npm due to current limitations with bun | |
if: | | |
github.ref == 'refs/heads/main' && | |
github.event.repository.fork == false && | |
github.actor != 'dependabot[bot]' | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 2 | |
environment: FSI_DEP_NodeJs | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js ${{ vars.NODE_VERSION }} for NPM registry | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ vars.NODE_VERSION }} | |
registry-url: "https://registry.npmjs.org/" | |
scope: ${{ vars.NPM_ORG }} | |
always-auth: true | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ vars.DEMO_PATH }} | |
- name: Get package version | |
id: get_version | |
run: echo "VERSION=$(jq -r .version < ./${{ vars.DEMO_PATH }}/package.json)" >> $GITHUB_OUTPUT | |
- name: Determine tag | |
id: determine_tag | |
run: | | |
VERSION=${{ steps.get_version.outputs.VERSION }} | |
if [[ "$VERSION" == *"-beta"* ]]; then | |
echo "TAG=beta" >> $GITHUB_OUTPUT | |
elif [[ "$VERSION" == *"-alpha"* ]]; then | |
echo "TAG=alpha" >> $GITHUB_OUTPUT | |
elif [[ "$VERSION" == *"-rc"* ]]; then | |
echo "TAG=rc" >> $GITHUB_OUTPUT | |
elif [[ "$VERSION" == *"-next"* ]]; then | |
echo "TAG=next" >> $GITHUB_OUTPUT | |
else | |
echo "TAG=latest" >> $GITHUB_OUTPUT | |
fi | |
- name: Release to NPM registry 🚀 - ${{ steps.get_version.outputs.VERSION }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
cd ./${{ vars.DEMO_PATH }} | |
npm publish --tag ${{ steps.determine_tag.outputs.TAG }} --access public || echo "Package already published in NPM, skipping..." | |
- name: Set up Node.js ${{ vars.NODE_VERSION }} for GitHub NPM registry | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ vars.NODE_VERSION }} | |
registry-url: "https://npm.pkg.github.com/" | |
scope: ${{ vars.NPM_ORG }} | |
always-auth: true | |
- name: Release to GitHub NPM registry 🚀 - ${{ steps.get_version.outputs.VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_GH_TOKEN }} | |
run: | | |
cd ./${{ vars.DEMO_PATH }} | |
npm publish --tag ${{ steps.determine_tag.outputs.TAG }} && npx semantic-release || echo "Package already published in GitHub NPM, skipping..." |