-
-
Notifications
You must be signed in to change notification settings - Fork 7
84 lines (73 loc) · 2.74 KB
/
release.yaml
File metadata and controls
84 lines (73 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
publish_latest:
description: "Retry a failed latest publish (skips pre-mode check, publishes whatever's in package.json under the 'latest' tag). Leave off for normal prerelease dispatch."
required: false
default: false
type: boolean
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
id-token: write # Required for OIDC
contents: write
pull-requests: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Create Release PR or Publish
if: github.event_name == 'push'
id: changesets
uses: changesets/action@v1
with:
publish: npm run release
title: "chore: release packages 📦"
commit: "chore: release packages 📦"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate dispatch mode
if: github.event_name == 'workflow_dispatch'
env:
PUBLISH_LATEST: ${{ inputs.publish_latest }}
run: |
if [ "$PUBLISH_LATEST" = "true" ]; then
if [ -f .changeset/pre.json ]; then
echo "::error::publish_latest is true but .changeset/pre.json exists. Exit pre mode before publishing to latest."
exit 1
fi
echo "publish_latest=true: will publish under 'latest' (retry path)."
exit 0
fi
if [ ! -f .changeset/pre.json ]; then
echo "::error::Prerelease dispatch requires changesets pre mode. Run 'npx changeset pre enter <tag>' on the branch first, or re-dispatch with publish_latest=true to retry a latest publish."
exit 1
fi
- name: Build
if: github.event_name == 'workflow_dispatch'
run: npm run build
# Manual dispatch publishes whatever's already versioned on the branch.
# In pre mode, the dist-tag comes from .changeset/pre.json.
# With publish_latest=true, it retries a failed latest publish (--provenance
# mirrors the push-trigger path).
- name: Publish (prerelease)
if: github.event_name == 'workflow_dispatch' && inputs.publish_latest != true
run: ./node_modules/.bin/changeset publish
- name: Publish (latest retry)
if: github.event_name == 'workflow_dispatch' && inputs.publish_latest == true
run: ./node_modules/.bin/changeset publish --provenance