Skip to content

Commit f066f44

Browse files
Wenxin-Jiangclaude
andauthored
fix: simplify release to workflow_dispatch (no bot commits) (#48)
* fix: simplify release to workflow_dispatch (no bot commits needed) Replace the two-workflow PR-based release flow with a single workflow_dispatch trigger, matching the socket-cli pattern. Changes: - Remove release-prep.yml (automated version bump + PR creation) - Make release.yml a manual workflow_dispatch that reads the version from Cargo.toml, tags, builds, and publishes - Add dry-run option to build without publishing - Use NPM_TOKEN secret for npm publish (fixes ENEEDAUTH on new packages) - Add registry-url to setup-node for proper auth Release flow after this change: 1. Bump version in a PR: run scripts/version-sync.sh, commit, merge 2. Click "Run workflow" on Release 3. Done - tags, builds, and publishes automatically This avoids the signed commit requirement that blocked github-actions[bot] from pushing to protected branches. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove NPM_TOKEN, use OIDC trusted publishing like socket-cli The original ENEEDAUTH failure was caused by missing registry-url in setup-node, not missing NPM_TOKEN. With registry-url set, OIDC trusted publishing works for both existing and new packages. Also fixes zizmor secrets-outside-env warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: restore NPM_TOKEN with environment for new package publishing OIDC trusted publishing doesn't work for brand new packages that don't exist on the npm registry yet. The new -gnu/-musl packages need NPM_TOKEN for their first publish. Added `environment: npm-publish` to satisfy zizmor's secrets-outside-env audit. The environment needs to be created in the repo settings with the NPM_TOKEN secret. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use pure OIDC trusted publishing, matching socket-cli/socket-mcp Remove NPM_TOKEN and environment — use the same OIDC pattern as socket-cli and socket-mcp. The registry-url in setup-node enables the OIDC token exchange. Note: new packages that don't exist on npm yet must be pre-created manually before the first publish. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 64c0140 commit f066f44

File tree

2 files changed

+41
-103
lines changed

2 files changed

+41
-103
lines changed

.github/workflows/release-prep.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,60 @@
11
name: Release
22

33
on:
4-
pull_request:
5-
types: [closed]
6-
branches: [main]
4+
workflow_dispatch:
5+
inputs:
6+
dry-run:
7+
description: 'Dry run (build only, skip publish)'
8+
type: boolean
9+
default: false
710

811
permissions: {}
912

1013
jobs:
11-
check-release:
12-
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
14+
version:
1315
runs-on: ubuntu-latest
1416
outputs:
15-
version: ${{ steps.extract.outputs.VERSION }}
17+
version: ${{ steps.read.outputs.VERSION }}
1618
steps:
17-
- name: Extract version from branch name
18-
id: extract
19-
env:
20-
HEAD_REF: ${{ github.event.pull_request.head.ref }}
19+
- name: Checkout
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
with:
22+
persist-credentials: false
23+
24+
- name: Read version from Cargo.toml
25+
id: read
2126
run: |
22-
VERSION="${HEAD_REF#release/v}"
27+
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
2328
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
24-
echo "Detected release version: $VERSION"
29+
echo "Release version: $VERSION"
30+
31+
- name: Check tag does not exist
32+
run: |
33+
VERSION="${{ steps.read.outputs.VERSION }}"
34+
if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
35+
echo "::error::Tag v${VERSION} already exists. Bump the version in a PR first."
36+
exit 1
37+
fi
2538
2639
tag:
27-
needs: check-release
40+
needs: version
41+
if: ${{ !inputs.dry-run }}
2842
runs-on: ubuntu-latest
2943
permissions:
3044
contents: write
3145
steps:
3246
- name: Checkout
3347
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3448

35-
- name: Configure Git
36-
run: |
37-
git config user.name "github-actions[bot]"
38-
git config user.email "github-actions[bot]@users.noreply.github.com"
39-
4049
- name: Create and push tag
4150
run: |
42-
VERSION="${{ needs.check-release.outputs.version }}"
43-
TAG="v${VERSION}"
44-
if git rev-parse "$TAG" >/dev/null 2>&1; then
45-
echo "::error::Tag $TAG already exists."
46-
exit 1
47-
fi
51+
TAG="v${{ needs.version.outputs.version }}"
4852
git tag "$TAG"
4953
git push origin "$TAG"
5054
5155
build:
52-
needs: [check-release, tag]
56+
needs: [version, tag]
57+
if: ${{ always() && needs.version.result == 'success' && (needs.tag.result == 'success' || needs.tag.result == 'skipped') }}
5358
strategy:
5459
matrix:
5560
include:
@@ -116,7 +121,6 @@ jobs:
116121
- name: Checkout
117122
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
118123
with:
119-
ref: v${{ needs.check-release.outputs.version }}
120124
persist-credentials: false
121125

122126
- name: Install Rust
@@ -165,7 +169,8 @@ jobs:
165169
path: socket-patch-${{ matrix.target }}.zip
166170

167171
github-release:
168-
needs: [check-release, build]
172+
needs: [version, build]
173+
if: ${{ !inputs.dry-run }}
169174
runs-on: ubuntu-latest
170175
permissions:
171176
contents: write
@@ -180,14 +185,15 @@ jobs:
180185
env:
181186
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182187
run: |
183-
TAG="v${{ needs.check-release.outputs.version }}"
188+
TAG="v${{ needs.version.outputs.version }}"
184189
gh release create "$TAG" \
185190
--repo "$GITHUB_REPOSITORY" \
186191
--generate-notes \
187192
artifacts/*
188193
189194
cargo-publish:
190-
needs: [check-release, build]
195+
needs: [version, build]
196+
if: ${{ !inputs.dry-run }}
191197
runs-on: ubuntu-latest
192198
permissions:
193199
contents: read
@@ -196,7 +202,6 @@ jobs:
196202
- name: Checkout
197203
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
198204
with:
199-
ref: v${{ needs.check-release.outputs.version }}
200205
persist-credentials: false
201206

202207
- name: Install Rust
@@ -225,7 +230,8 @@ jobs:
225230
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
226231

227232
npm-publish:
228-
needs: [check-release, build]
233+
needs: [version, build]
234+
if: ${{ !inputs.dry-run }}
229235
runs-on: ubuntu-latest
230236
permissions:
231237
contents: read
@@ -234,7 +240,6 @@ jobs:
234240
- name: Checkout
235241
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
236242
with:
237-
ref: v${{ needs.check-release.outputs.version }}
238243
persist-credentials: false
239244

240245
- name: Configure git for HTTPS
@@ -250,6 +255,7 @@ jobs:
250255
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
251256
with:
252257
node-version: '22'
258+
registry-url: 'https://registry.npmjs.org'
253259

254260
- name: Update npm for trusted publishing
255261
run: npm install -g npm@latest
@@ -301,7 +307,8 @@ jobs:
301307
run: npm publish ./npm/socket-patch --provenance --access public
302308

303309
pypi-publish:
304-
needs: [check-release, build]
310+
needs: [version, build]
311+
if: ${{ !inputs.dry-run }}
305312
runs-on: ubuntu-latest
306313
permissions:
307314
contents: read
@@ -310,7 +317,6 @@ jobs:
310317
- name: Checkout
311318
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
312319
with:
313-
ref: v${{ needs.check-release.outputs.version }}
314320
persist-credentials: false
315321

316322
- name: Download all artifacts
@@ -329,7 +335,7 @@ jobs:
329335

330336
- name: Build platform wheels
331337
run: |
332-
VERSION="${{ needs.check-release.outputs.version }}"
338+
VERSION="${{ needs.version.outputs.version }}"
333339
python scripts/build-pypi-wheels.py --version "$VERSION" --artifacts artifacts --dist dist
334340
335341
- name: Publish to PyPI

0 commit comments

Comments
 (0)