Release litlytics library #3
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 litlytics library | |
on: | |
workflow_run: | |
# Run after "Test and lint" workflow | |
workflows: ['Test and lint'] | |
types: | |
- completed # Only when it's completed | |
branches: | |
- main # Only run the publish workflow for pushes to main | |
jobs: | |
publish-lib: | |
environment: Github CI | |
# Only proceed if the tests passed and we're on release | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} && ${{ startsWith(github.ref, 'refs/tags/') }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Check for changes in ./packages/litlytics | |
- name: Check if changed | |
id: changes | |
run: | | |
# Check if any files changed in the specified directory | |
if git diff --quiet HEAD^ HEAD ./packages/litlytics; then | |
echo "No changes in ./packages/litlytics. Skipping publish." | |
echo "should_publish=false" >> $GITHUB_ENV | |
else | |
echo "Changes detected in ./packages/litlytics." | |
echo "should_publish=true" >> $GITHUB_ENV | |
fi | |
# install node (for npm utils) | |
- name: Install node for npm checks | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
registry-url: 'https://registry.npmjs.org' | |
# install bun | |
- name: Install bun for deployment | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
# Install dependencies | |
- name: Install dependencies | |
working-directory: ./packages/litlytics | |
run: bun install --frozen-lockfile | |
# Build package | |
- name: Build package | |
working-directory: ./packages/litlytics | |
run: bun run build | |
# install and publish if local version is not the same as published | |
- name: publish | |
if: ${{ env.should_publish == 'true' }} | |
working-directory: ./packages/litlytics | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |