Repository navigation
174 lines (152 loc) · 6.02 KB
/
Copy pathrelease.yml
File metadata and controls
174 lines (152 loc) · 6.02 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Release
# Publishing is driven by a version tag, not by a commit pushed from CI. The
# version bump lands through a normal reviewed pull request; pushing the
# matching tag afterwards triggers the publish. CI never writes to git.
# See RELEASING.md.
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
# Rehearsal against the current branch. Always a dry run: it validates the
# version and the full gate without tagging or publishing anything.
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
# Native pull request runs are `paths:`-filtered and advisory; this is what
# actually stops a broken native build from being published. It builds the
# Release configuration, including the 32-bit Android ABI.
native:
permissions:
contents: read
uses: ./.github/workflows/native-build.yml
with:
configuration: release
release:
needs: [native]
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
# Create the GitHub Release for the pushed tag.
contents: write
# Mint the OIDC token npm exchanges for a short-lived publish token, and
# sign the provenance attestation.
id-token: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Full history so conventional-changelog can build the release notes
# from every commit since the previous tag.
fetch-depth: 0
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: package.json
- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
# Node 24 ships npm >= 11.5.1, required for npm trusted publishing.
# `registry-url` is deliberately omitted: it writes an `_authToken`
# entry into .npmrc, which makes npm assume classic token auth and
# skip the OIDC flow. The registry is pinned by publishConfig.
node-version: 24
- name: Verify npm supports trusted publishing
run: |
npm_version="$(npm --version)"
required=11.5.1
echo "npm $npm_version (need >= $required)"
if [ "$(printf '%s\n%s\n' "$required" "$npm_version" | sort -V | head -n1)" != "$required" ]; then
echo "::error::npm $npm_version is too old for trusted publishing (need >= $required)."
exit 1
fi
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Resolve version
id: version
run: |
version="$(node -p "require('./package/package.json').version")"
echo "package.json version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Verify tag matches package.json
if: github.event_name == 'push'
env:
VERSION: ${{ steps.version.outputs.version }}
TAG: ${{ github.ref_name }}
run: |
if [ "$TAG" != "v$VERSION" ]; then
echo "::error::Tag $TAG does not match package.json version $VERSION. Bump the version on main first."
exit 1
fi
- name: Verify version is not already published
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
if npm view "react-native-better-clustering@$VERSION" version >/dev/null 2>&1; then
echo "::error::react-native-better-clustering@$VERSION is already on npm. Bump the version on main first."
exit 1
fi
- name: Codegen
working-directory: package
run: bun run specs
- name: Lint
run: bun run lint
- name: Format check
run: bun run format:check
- name: Typecheck
working-directory: package
run: bun run typecheck
- name: Build
working-directory: package
run: bun run build
- name: Test
working-directory: package
run: bun run test:ci
- name: Verify package contents
working-directory: package
run: bun run verify:pack
- name: Verify package exports
working-directory: package
run: bun run verify:exports
- name: Copy README into the package
# npm reads the README shown on the registry page from the package
# directory while it builds the manifest, before any pack script runs.
# The `prepack` copy therefore never reaches the registry (1.0.0 shows
# "No README data found!"); the file must exist here first.
run: cp README.md package/README.md
- name: Publish
working-directory: package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT_NAME: ${{ github.event_name }}
run: |
# --no-increment: the version already lives in package.json, reviewed
# and merged through a pull request.
# --no-git: the tag is pushed by the maintainer; CI never writes to git.
args=(--ci --no-increment --no-git)
if [ "$EVENT_NAME" != 'push' ]; then
args+=(--dry-run)
echo 'Rehearsal run — nothing will be tagged or published.'
fi
bunx release-it "${args[@]}"
- name: Summary
if: always()
env:
VERSION: ${{ steps.version.outputs.version }}
EVENT_NAME: ${{ github.event_name }}
SERVER_URL: ${{ github.server_url }}
REPOSITORY: ${{ github.repository }}
run: |
{
echo "### Release v$VERSION"
echo
if [ "$EVENT_NAME" != 'push' ]; then
echo "Rehearsal only — nothing was published."
else
echo "- [npm](https://www.npmjs.com/package/react-native-better-clustering/v/$VERSION)"
echo "- [GitHub Release]($SERVER_URL/$REPOSITORY/releases/tag/v$VERSION)"
fi
} >> "$GITHUB_STEP_SUMMARY"