Skip to content

Release Library

Release Library #94

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:
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 Bun - Version ${{ vars.BUN_VERSION }} for NPM registry
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ vars.BUN_VERSION }}
registry-url: "https://registry.npmjs.org/"
scope: ${{ vars.NPM_ORG }}
- 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:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Use this line if you are using NPM/YARN as a package manager
run: |
cd ./${{ vars.DEMO_PATH }}
bun publish --tag ${{ steps.determine_tag.outputs.TAG }} --access public || echo "Package already published in NPM, skipping..."
- name: Set up Bun - Version ${{ vars.BUN_VERSION }} for GitHub NPM registry
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ vars.BUN_VERSION }}
registry-url: "https://npm.pkg.github.com/"
scope: ${{ vars.NPM_ORG }}
- name: Release to GitHub NPM registry 🚀 - ${{ steps.get_version.outputs.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_TOKEN: ${{ secrets.NPM_GH_TOKEN }}
BUN_AUTH_TOKEN: ${{ secrets.NPM_GH_TOKEN }}
run: |
cd ./${{ vars.DEMO_PATH }}
bun publish --tag ${{ steps.determine_tag.outputs.TAG }} && bunx semantic-release || echo "Package already published in GitHub NPM, skipping..."