Repository navigation
275 lines (245 loc) · 10.5 KB
/
Copy pathrelease.yml
File metadata and controls
275 lines (245 loc) · 10.5 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Release
# Release is triggered by pushing a vX.Y.Z tag.
#
# PREREQUISITE: Before tagging, merge develop → main via PR.
# The tag must point to a commit on main, NOT develop.
# GitFlow: develop (default) → PR → main → tag → release.
#
# This workflow does NOT sync main — main must already be up to date.
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
verify-main:
name: Verify tag is on main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check tag is on main
run: |
git fetch origin main
TAG_SHA=$(git rev-parse "${{ github.ref }}^{commit}")
MAIN_SHA=$(git rev-parse origin/main)
echo "Tag: $TAG_SHA"
echo "main: $MAIN_SHA"
if [ "$TAG_SHA" = "$MAIN_SHA" ]; then
echo "✅ Tag is main HEAD"
elif git merge-base --is-ancestor "$TAG_SHA" origin/main 2>/dev/null; then
echo "✅ Tag commit $TAG_SHA is in main history"
else
echo "::error::Tag commit $TAG_SHA is NOT on main."
echo "Merge develop → main via PR before tagging."
exit 1
fi
build-release:
needs: [verify-main]
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: cora-x86_64-unknown-linux-gnu
ext: tar.gz
# Linux ARM64
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
artifact: cora-aarch64-unknown-linux-gnu
ext: tar.gz
# macOS Apple Silicon
- os: macos-latest
target: aarch64-apple-darwin
artifact: cora-aarch64-apple-darwin
ext: tar.gz
# Windows x86_64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: cora-x86_64-pc-windows-msvc
ext: zip
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y musl-tools
# The release binary carries the code embedding model (feature
# `bundled-model`), so a fresh download works with no network. The files are
# fetched at the pinned revision and verified against their SHA-256 (#761).
- name: Fetch the code model to bundle
shell: bash
run: |
dir="${RUNNER_TEMP//\\//}/potion-model"
scripts/fetch-model.sh "$dir"
echo "CORA_BUNDLED_MODEL_DIR=$dir" >> "$GITHUB_ENV"
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} --features tree-sitter,bundled-model
- name: Strip binary (Unix)
if: runner.os != 'Windows'
run: strip target/${{ matrix.target }}/release/cora
# Offline, empty data directory: the model must come from the binary itself.
- name: Smoke test the bundled model
shell: bash
run: |
bin="$GITHUB_WORKSPACE/target/${{ matrix.target }}/release/cora"
if [ "${{ runner.os }}" = "Windows" ]; then bin="$bin.exe"; fi
proj="${RUNNER_TEMP//\\//}/smoke-project"
home="${RUNNER_TEMP//\\//}/smoke-home"
mkdir -p "$proj" "$home"
printf '[package]\nname = "smoke"\nversion = "0.1.0"\nedition = "2021"\n' > "$proj/Cargo.toml"
printf 'pub fn load_settings_file(path: &str) {}\npub fn send_request_to_server(url: &str) {}\n' > "$proj/lib.rs"
cd "$proj"
export CODECORA_HOME="$home" CORA_EMBED_OFFLINE=1
"$bin" index
out=$("$bin" brain "send a network request" --json)
echo "$out"
echo "$out" | grep -q send_request_to_server
echo "$out" | grep -q '"vector"'
- name: Extract version
id: version
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Package (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/cora release/cora
cd release
tar czf ${{ matrix.artifact }}-${{ steps.version.outputs.VERSION }}.${{ matrix.ext }} cora
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
mkdir release
cp target/${{ matrix.target }}/release/cora.exe release/${{ matrix.artifact }}.exe
cd release
7z a ${{ matrix.artifact }}-${{ steps.version.outputs.VERSION }}.${{ matrix.ext }} ${{ matrix.artifact }}.exe
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}-${{ steps.version.outputs.VERSION }}
path: release/${{ matrix.artifact }}-${{ steps.version.outputs.VERSION }}.${{ matrix.ext }}
publish-crates:
name: Publish to crates.io
needs: [verify-main]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --allow-dirty
release:
name: Create GitHub Release
needs: [build-release]
runs-on: ubuntu-latest
# Least privilege, scoped to this job only:
# contents: write -> create the GitHub Release and upload assets
# id-token: write -> mint the GitHub OIDC token cosign exchanges for a
# short-lived Sigstore (Fulcio) signing certificate (#591)
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
merge-multiple: true
- name: List artifacts
run: ls -la release-artifacts/
- name: Generate SHA256 checksums
run: |
cd release-artifacts
sha256sum * > checksums-sha256.txt
cat checksums-sha256.txt
# Keyless signing (#591). Ordering matters: sign BEFORE creating the
# release. If signing fails the job stops here and no release is
# published, so we never ship a release that lacks its signature.
# One signature over the checksums file covers every archive, because
# install.sh / `cora upgrade` verify each archive against that file.
# sigstore/cosign-installer v3.10.1, pinned by commit SHA.
- name: Install cosign
uses: sigstore/cosign-installer@7e8b541eb2e61bf99390e1afd4be13a184e9ebc5
with:
cosign-release: 'v2.6.5'
- name: Sign checksums with cosign (keyless)
working-directory: release-artifacts
run: |
cosign sign-blob --yes \
--bundle checksums-sha256.txt.sigstore.json \
checksums-sha256.txt
test -s checksums-sha256.txt.sigstore.json
# Fail the job (before publishing) if the bundle does not verify against
# this exact workflow identity.
- name: Verify the fresh signature
working-directory: release-artifacts
run: |
cosign verify-blob \
--bundle checksums-sha256.txt.sigstore.json \
--certificate-identity "https://github.com/${GITHUB_REPOSITORY}/.github/workflows/release.yml@${GITHUB_REF}" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
checksums-sha256.txt
- name: Extract version from tag
id: version
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/}"
SEMVER="${TAG_VERSION#v}"
# Validate semver format (digits.digits.digits only — prevents sed injection)
if ! echo "$SEMVER" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "ERROR: Invalid semver format: $SEMVER"
exit 1
fi
echo "TAG=$TAG_VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$SEMVER" >> $GITHUB_OUTPUT
- name: Extract changelog for this version
id: changelog
run: |
CHANGELOG_EXCERPT=$(sed -n '/^## \['"${{ steps.version.outputs.VERSION }}"'\]/,/^## \[/p' CHANGELOG.md | sed '$d' | tail -n +2)
{
printf '## What'\''s New in %s\n\n' "${{ steps.version.outputs.TAG }}"
printf '%s\n\n' "$CHANGELOG_EXCERPT"
printf '### 📦 Platforms\n\n'
printf '| Platform | File |\n'
printf '|----------|------|\n'
printf '| Linux (x86_64) | `cora-x86_64-unknown-linux-gnu-%s.tar.gz` |\n' "${{ steps.version.outputs.TAG }}"
printf '| Linux (ARM64) | `cora-aarch64-unknown-linux-gnu-%s.tar.gz` |\n' "${{ steps.version.outputs.TAG }}"
printf '| macOS (Apple Silicon) | `cora-aarch64-apple-darwin-%s.tar.gz` |\n' "${{ steps.version.outputs.TAG }}"
printf '| Windows (x86_64) | `cora-x86_64-pc-windows-msvc-%s.zip` |\n\n' "${{ steps.version.outputs.TAG }}"
printf 'The archives above contain the code embedding model, so semantic search works right after the download, offline included.\n\n'
printf '### 🚀 Quick Start\n\n'
printf '```bash\n'
printf '# Quick install (Linux / macOS)\n'
printf 'curl -fsSL https://raw.githubusercontent.com/codecoradev/cora-code/main/install.sh | sh\n\n'
printf '# Or via cargo (builds from source; downloads the 33.5 MB code model on first use)\n'
printf 'cargo install cora-code\n\n'
printf '# Init project\n'
printf 'cora init\n\n'
printf '# Review staged changes\n'
printf 'CORA_API_KEY=your-key cora review --staged\n'
printf '```\n\n'
printf '**Full changelog:** https://github.com/codecoradev/cora-code/blob/main/CHANGELOG.md\n'
} > release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.TAG }}
name: Release ${{ steps.version.outputs.TAG }}
body_path: release-notes.md
files: release-artifacts/*
draft: false
prerelease: ${{ contains(steps.version.outputs.TAG, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}