Skip to content

feat: action menu (#183) #51

feat: action menu (#183)

feat: action menu (#183) #51

name: Publish canary release

Check failure on line 1 in .github/workflows/publish-canary-release.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-canary-release.yaml

Invalid workflow file

(Line: 43, Col: 9): Unrecognized named-value: 'matrix'. Located at position 100 within expression: github.event_name == 'pull_request' || inputs.package == 'both' || (inputs.package == 'filters' && matrix.package == 'filters') || (inputs.package == 'action-menu' && matrix.package == 'action-menu')
on:
workflow_dispatch:
inputs:
package:
description: "Which package(s) to release"
type: choice
options: [filters, action-menu, both]
default: both
required: true
bump_type:
description: "Bump type"
type: choice
options: [patch, minor, major]
default: patch
required: true
npm_tag:
description: "npm dist-tag"
type: choice
options: [canary, latest]
default: canary
required: true
dry_run:
description: "Run in dry-run mode (no publish or git push)"
type: boolean
default: false
pull_request:
branches: [canary]
jobs:
publish-canary:
permissions:
contents: write
runs-on: ubuntu-24.04
# serialize matrix to avoid concurrent commits/tags racing
strategy:
max-parallel: 1
matrix:
package: [filters, action-menu]
# Skip matrix rows not selected by input
if: >
github.event_name == 'pull_request' ||
inputs.package == 'both' ||
(inputs.package == 'filters' && matrix.package == 'filters') ||
(inputs.package == 'action-menu' && matrix.package == 'action-menu')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: "package.json"
- name: Setup Node.js for npm
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- name: Install dependencies
run: bun i --frozen-lockfile
- name: Set up .npmrc for authentication
if: github.event_name != 'pull_request' && !inputs.dry_run
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build & release ${{ matrix.package }}
working-directory: packages/${{ matrix.package }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# build (your publish.ts runs tests again as well)
bun run build
# Decide flags based on event + dry_run
EXTRA_FLAGS="--no-git-tag --tag ${{ inputs.npm_tag }}"
if [[ "${{ github.event_name }}" == "pull_request" || "${{ inputs.dry_run }}" == "true" ]]; then
EXTRA_FLAGS="$EXTRA_FLAGS --dry-run"
fi
# Call your release script directly (uses your custom versioning)
bun scripts/release.ts --bump ${{ inputs.bump_type }} --path . $EXTRA_FLAGS
- name: Commit version bump for ${{ matrix.package }}
if: github.event_name != 'pull_request' && !inputs.dry_run
working-directory: packages/${{ matrix.package }}
run: |
PKG_NAME=$(jq -r '.name' package.json)
NEXT_VERSION=$(jq -r '.version' package.json)
git add package.json
git commit -m "release(${PKG_NAME}): v${NEXT_VERSION}"
- name: Create per-package tag for ${{ matrix.package }}
if: github.event_name != 'pull_request' && !inputs.dry_run
working-directory: packages/${{ matrix.package }}
run: |
PKG_NAME=$(jq -r '.name' package.json)
NEXT_VERSION=$(jq -r '.version' package.json)
# Sanitize tag so it doesn't contain '/'
TAG_NAME="${PKG_NAME}@${NEXT_VERSION}"
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
- name: Push branch (after commit)
if: github.event_name != 'pull_request' && !inputs.dry_run
run: |
git push origin HEAD