Skip to content

Commit ad178d4

Browse files
allow releasing tags
1 parent a14b4cc commit ad178d4

1 file changed

Lines changed: 37 additions & 9 deletions

File tree

.github/workflows/release.yaml

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
push:
55
branches:
66
- main
7+
workflow_dispatch:
8+
inputs:
9+
npm_tag:
10+
description: "npm dist-tag to publish under. Manual releases cannot use latest."
11+
required: true
12+
type: string
713

814
concurrency: ${{ github.workflow }}-${{ github.ref }}
915

@@ -19,24 +25,20 @@ jobs:
1925
steps:
2026
- name: Checkout
2127
uses: actions/checkout@v6
22-
# with:
23-
# Figure out later if needed
24-
# fetch-depth: 0
28+
with:
29+
fetch-depth: 0
2530

2631
- name: Setup Node.js
2732
uses: actions/setup-node@v6
2833
with:
2934
node-version: 24
35+
registry-url: "https://registry.npmjs.org"
3036

3137
- name: Install dependencies
3238
run: npm ci
3339

34-
- name: Diagnose npm
35-
run: |
36-
npm --version
37-
npm whoami --registry=https://registry.npmjs.org || true
38-
3940
- name: Create Release PR or Publish
41+
if: github.event_name == 'push'
4042
id: changesets
4143
uses: changesets/action@v1
4244
with:
@@ -45,4 +47,30 @@ jobs:
4547
commit: "chore: release packages 📦"
4648
env:
4749
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
# NPM_TOKEN - OIDC handles auth...in theory
50+
51+
- name: Validate manual npm tag
52+
if: github.event_name == 'workflow_dispatch'
53+
env:
54+
NPM_TAG: ${{ inputs.npm_tag }}
55+
run: |
56+
if [ "$NPM_TAG" = "latest" ]; then
57+
echo "::error::Manual releases cannot publish to latest. Pushes to main publish to latest automatically."
58+
exit 1
59+
fi
60+
if ! echo "$NPM_TAG" | grep -Eq '^[a-z][a-z0-9-]*$'; then
61+
echo "::error::npm_tag must match ^[a-z][a-z0-9-]*$."
62+
exit 1
63+
fi
64+
65+
- name: Build
66+
if: github.event_name == 'workflow_dispatch'
67+
run: npm run build
68+
69+
# Manual dispatch publishes packages from the selected ref that are not
70+
# already on the registry under a non-latest npm dist-tag, for compatibility
71+
# or preview channels. It does not retag already-published versions.
72+
- name: Publish with manual npm tag
73+
if: github.event_name == 'workflow_dispatch'
74+
run: ./node_modules/.bin/changeset publish --tag "$NPM_TAG"
75+
env:
76+
NPM_TAG: ${{ inputs.npm_tag }}

0 commit comments

Comments
 (0)