Skip to content

Update package versions #14

Update package versions

Update package versions #14

Workflow file for this run

name: Update package versions
on:
workflow_dispatch:
inputs:
update_type:
description: "Verion update type"
required: true
# Change to minor once project is stable
default: "prepatch"
type: choice
options:
- patch
- minor
- major
- prepatch
- preminor
- premajor
prerelease_identifier:
description: "Pre-release identifier, used for pre(patch|minor|major) versions"
default: "experimental"
required: false
type: string
env:
MAIN_BRANCH: "refs/heads/main"
jobs:
build:
name: Build & test
runs-on: ubuntu-latest
steps:
- name: Validate input
run: |
if [[ "${{ github.ref }}" != "${{ env.MAIN_BRANCH }}" ]]; then
echo "This action can only be run on the main branch"
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
# "prepare" hook on `bun install` runs `bun run build`
- name: Setup environment
uses: ./.github/actions/setup-env
# TODO add Nx and only test the packages that have changed since last tag
- name: Code quality checks
run: bun run check
- name: Test
run: bun run test
version:
name: Bump package versions
runs-on: ubuntu-latest
needs: build
outputs:
VERSION: ${{ steps.lerna_version.outputs.VERSION }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
# Lerna needs *all* the git history to determine which packages have changed
fetch-depth: 0
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Bump package versions
id: lerna_version
uses: ./.github/actions/lerna-version
with:
update_type: ${{ github.event.inputs.update_type }}
prerelease_identifier: ${{ github.event.inputs.prerelease_identifier }}
- name: Setup Git CLI
uses: ./.github/actions/setup-git
with:
name: ${{ github.actor }}
- name: Commit and tag v${{ steps.lerna_version.outputs.VERSION }}
run: |
git add .
git commit -m "chore: version bump to ${{ steps.lerna_version.outputs.VERSION }}"
# Create an annotated tag (`-m`) so that lerna can use it to determine which packages have changed
# See https://github.com/lerna/lerna/issues/1357#issuecomment-438162152
git tag "v${{ steps.lerna_version.outputs.VERSION }}" -m "v${{ steps.lerna_version.outputs.VERSION }}"
git push && git push --tags
publish:
name: Publish packages
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Checkout the tag that was just created
ref: v${{ needs.version.outputs.VERSION }}
# Lerna needs *all* the git history to determine which packages have changed
fetch-depth: 0
# "prepare" hook on `bun install` runs `bun run build`
- name: Setup Environment
uses: ./.github/actions/setup-env
- name: Setup Node, authenticate with NPM registry
uses: actions/[email protected]
with:
node-version: 22
registry-url: https://registry.npmjs.org
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Publish packages
run: lerna publish --yes --no-private from-package