Publish canary (action-menu) #1
This file contains hidden or 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: Publish canary (action-menu) | |
on: | |
workflow_dispatch: | |
inputs: | |
bump_type: | |
description: "Bump type" | |
type: choice | |
options: [patch, minor, major] | |
default: patch | |
npm_tag: | |
description: "npm dist-tag" | |
type: choice | |
options: [canary, latest] | |
default: canary | |
dry_run: | |
description: "Dry run (no publish/push)" | |
type: boolean | |
default: false | |
jobs: | |
publish: | |
permissions: | |
contents: write | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
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 deps | |
run: bun i --frozen-lockfile | |
- name: Set up .npmrc | |
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 action menu | |
working-directory: packages/action-menu | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
bun run build | |
# defaults for PRs (no inputs) → canary/patch + dry-run | |
BUMP="${{ inputs.bump_type }}" | |
TAG="${{ inputs.npm_tag }}" | |
[ -z "$BUMP" ] && BUMP="patch" | |
[ -z "$TAG" ] && TAG="canary" | |
EXTRA="--no-git-tag --tag $TAG" | |
if [ "${{ github.event_name }}" = "pull_request" ] || [ "${{ inputs.dry_run }}" = "true" ]; then | |
EXTRA="$EXTRA --dry-run" | |
fi | |
bun scripts/release.ts --bump "$BUMP" --path . $EXTRA | |
- name: Commit version bump | |
if: ${{ github.event_name != 'pull_request' && !inputs.dry_run }} | |
working-directory: packages/action-menu | |
run: | | |
NEXT_VERSION=$(jq -r '.version' package.json) | |
git add package.json | |
git commit -m "release(action-menu): v${NEXT_VERSION}" | |
- name: Create per-package tag | |
if: ${{ github.event_name != 'pull_request' && !inputs.dry_run }} | |
working-directory: packages/action-menu | |
run: | | |
PKG_NAME=$(jq -r '.name' package.json) | |
NEXT_VERSION=$(jq -r '.version' package.json) | |
TAG_NAME="${PKG_NAME}@${NEXT_VERSION}" | |
git tag "$TAG_NAME" | |
git push origin "$TAG_NAME" | |
- name: Push branch | |
if: ${{ github.event_name != 'pull_request' && !inputs.dry_run }} | |
run: git push origin HEAD |