-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (143 loc) ยท 6.06 KB
/
Copy pathrelease.yml
File metadata and controls
161 lines (143 loc) ยท 6.06 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
# Release workflow for deep-code
#
# ่งฆๅๆกไปถ๏ผๆจ้ v* ๆ ็ญพ๏ผๅฆ v0.1.0๏ผ
# ๆง่ก๏ผๅคๅนณๅฐ็ผ่ฏ โ GitHub Release โ npm publish
#
# ๅ็ฝฎๆกไปถ๏ผnpm ไพงๆๆฌไปๅบ้
ๆ่ฏฅๅ
็ trusted publisher๏ผOIDC๏ผใ
# ไธ้่ฆ NPM_TOKEN โโ publish ๆญฅ้ชค่ตฐ id-token ๆ้๏ผๆ tokenใๆ OTPใ
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# ้ถๆฎต 1๏ผๅนถ่ก็ผ่ฏ 5 ไธชๅนณๅฐ
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
build:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: darwin-arm64
os: macos-latest
target: aarch64-apple-darwin
- name: darwin-x64
# Intel macOS runners (macos-13) are scarce/retiring and can queue
# forever; cross-compile x86_64 on the arm64 runner instead.
os: macos-latest
target: x86_64-apple-darwin
# Pinned to the OLDEST available Ubuntu runner on purpose: a
# `-gnu` binary requires at least the glibc it was linked against, and
# `ubuntu-latest` (24.04, glibc 2.39) produced binaries that refused to
# start on Ubuntu 22.04, Debian 12, RHEL 9 and Amazon Linux 2023 โ i.e.
# most of the installed base. `npm i -g` succeeded and then every run
# died with `GLIBC_2.3x not found`. 22.04 lowers the floor to glibc
# 2.35. Do not "modernize" these back to `-latest`.
- name: linux-x64
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- name: linux-arm64
os: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
- name: win32-x64
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
# Pinned to match rust-toolchain.toml; bump both together.
uses: dtolnay/rust-toolchain@1.96.0
with:
targets: ${{ matrix.target }}
# The release pipeline used to go straight from build to npm publish with
# no test gate at all, so tagging a commit whose CI was red (or tagging
# before CI finished) shipped a broken binary as npm `latest`. Host-native
# (no `--target`): a cross-compiled artifact cannot be executed here, but
# the workspace tests still run on every platform in the matrix.
- name: Test
run: cargo test --locked --workspace
- name: Build (release)
run: cargo build --locked --release --package deep-code-tui --target ${{ matrix.target }}
- name: Rename binary for release
shell: bash
run: |
TARGET="${{ matrix.target }}"
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp "target/${TARGET}/release/deep-code.exe" "deep-code-${TARGET}.exe"
else
cp "target/${TARGET}/release/deep-code" "deep-code-${TARGET}"
chmod +x "deep-code-${TARGET}"
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: deep-code-${{ matrix.target }}
path: deep-code-${{ matrix.target }}*
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# ้ถๆฎต 2๏ผGitHub Release + npm publish
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
publish:
name: Release & Publish
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # OIDC trusted publishing to npm (no token, no OTP)
steps:
- uses: actions/checkout@v4
- name: Verify tag matches package versions
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG="${GITHUB_REF_NAME#v}"
NPM=$(grep -m1 '"version"' packages/deepcode/package.json \
| sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
CARGO=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
echo "tag=$TAG npm=$NPM cargo=$CARGO"
if [ "$TAG" != "$NPM" ]; then
echo "::error::git tag v$TAG does not match packages/deepcode/package.json ($NPM)"
exit 1
fi
if [ "$TAG" != "$CARGO" ]; then
echo "::error::git tag v$TAG does not match Cargo.toml ($CARGO)"
exit 1
fi
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Prepare release assets
run: |
mkdir -p release-assets
find artifacts -type f | while read f; do
cp "$f" release-assets/
done
echo "=== Release assets ==="
ls -lh release-assets/
- name: Generate SHA256SUMS
working-directory: release-assets
run: |
sha256sum * > SHA256SUMS
echo "=== SHA256SUMS ==="
cat SHA256SUMS
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release-assets/*
generate_release_notes: true
fail_on_unmatched_files: true
# Node 24 ships with npm >= 11.5.1, meeting the OIDC trusted publishing
# requirement without a separate upgrade step that can break module paths.
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm (OIDC trusted publishing)
working-directory: packages/deepcode
# No NODE_AUTH_TOKEN: auth comes from GitHub OIDC via the package's
# configured trusted publisher, so it bypasses 2FA/OTP entirely.
run: npm publish --access public