Skip to content

Commit aeefbff

Browse files
committed
feat(ci): add dev/beta/nightly branch auto-deploy to R2
- Add dev-deploy.yml workflow triggered on beta/dev/nightly branches - Generates version strings: {base_version}-{channel}.{short_sha} - Builds CLI for all platforms (Linux/macOS/Windows, x64/ARM64) - Calls publish-r2.yml as reusable workflow - Update publish-r2.yml with latest symlink paths for each channel - Assets now uploaded to both versioned and {channel}/latest paths - Add dev channel to manifest.json initialization - Update summary with both versioned and latest-by-channel URLs
1 parent 7553256 commit aeefbff

File tree

2 files changed

+209
-4
lines changed

2 files changed

+209
-4
lines changed

.github/workflows/dev-deploy.yml

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: Dev/Beta Deploy to R2
2+
3+
on:
4+
push:
5+
branches:
6+
- beta
7+
- dev
8+
- nightly
9+
10+
env:
11+
BINARY_NAME: Cortex
12+
CARGO_TERM_COLOR: always
13+
RUST_BACKTRACE: 1
14+
RUSTFLAGS: "-Zthreads=32"
15+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
16+
CARGO_INCREMENTAL: 0
17+
18+
permissions:
19+
contents: read
20+
actions: read
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
# ==========================================================================
28+
# Prepare - Determine version and channel from branch
29+
# ==========================================================================
30+
prepare:
31+
name: Prepare Build
32+
runs-on: blacksmith-4vcpu-ubuntu-2404
33+
outputs:
34+
version: ${{ steps.version.outputs.version }}
35+
channel: ${{ steps.version.outputs.channel }}
36+
cache_key: ${{ steps.cache.outputs.key }}
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Generate cache key
41+
id: cache
42+
run: |
43+
echo "key=rust-dev-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}" >> $GITHUB_OUTPUT
44+
45+
- name: Determine version and channel
46+
id: version
47+
run: |
48+
# Read base version from VERSION_CLI
49+
BASE_VERSION=$(cat VERSION_CLI | tr -d '\n')
50+
51+
# Get short SHA (7 characters)
52+
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
53+
54+
# Determine channel from branch name
55+
BRANCH="${{ github.ref_name }}"
56+
case "$BRANCH" in
57+
beta)
58+
CHANNEL="beta"
59+
;;
60+
dev)
61+
CHANNEL="dev"
62+
;;
63+
nightly)
64+
CHANNEL="nightly"
65+
;;
66+
*)
67+
echo "ERROR: Unsupported branch '$BRANCH'"
68+
exit 1
69+
;;
70+
esac
71+
72+
# Generate version string: {base_version}-{channel}.{short_sha}
73+
VERSION="${BASE_VERSION}-${CHANNEL}.${SHORT_SHA}"
74+
75+
echo "Base version: $BASE_VERSION"
76+
echo "Channel: $CHANNEL"
77+
echo "Short SHA: $SHORT_SHA"
78+
echo "Full version: $VERSION"
79+
80+
echo "version=$VERSION" >> $GITHUB_OUTPUT
81+
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
82+
83+
# ==========================================================================
84+
# Build CLI Binaries (32 vCPU for compilation)
85+
# ==========================================================================
86+
build-cli:
87+
name: CLI ${{ matrix.artifact }}
88+
runs-on: ${{ matrix.runner }}
89+
needs: prepare
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
include:
94+
- runner: blacksmith-32vcpu-ubuntu-2404
95+
target: x86_64-unknown-linux-gnu
96+
artifact: cortex-cli-linux-x64
97+
ext: ""
98+
- runner: blacksmith-32vcpu-ubuntu-2404-arm
99+
target: aarch64-unknown-linux-gnu
100+
artifact: cortex-cli-linux-arm64
101+
ext: ""
102+
- runner: macos-latest
103+
target: x86_64-apple-darwin
104+
artifact: cortex-cli-macos-x64
105+
ext: ""
106+
- runner: macos-latest
107+
target: aarch64-apple-darwin
108+
artifact: cortex-cli-macos-arm64
109+
ext: ""
110+
- runner: blacksmith-32vcpu-windows-2025
111+
target: x86_64-pc-windows-msvc
112+
artifact: cortex-cli-windows-x64
113+
ext: .exe
114+
115+
steps:
116+
- uses: actions/checkout@v4
117+
118+
- name: Install Rust nightly
119+
uses: dtolnay/rust-toolchain@nightly
120+
with:
121+
targets: ${{ matrix.target }}
122+
123+
- name: Setup Rust cache (Blacksmith optimized)
124+
if: contains(matrix.runner, 'blacksmith')
125+
uses: useblacksmith/rust-cache@v3
126+
with:
127+
prefix-key: "rust-dev-cli-${{ matrix.target }}"
128+
shared-key: ${{ needs.prepare.outputs.cache_key }}
129+
130+
- name: Setup Rust cache (non-Blacksmith)
131+
if: "!contains(matrix.runner, 'blacksmith')"
132+
uses: Swatinem/rust-cache@v2
133+
with:
134+
prefix-key: "rust-dev-cli-${{ matrix.target }}"
135+
shared-key: ${{ needs.prepare.outputs.cache_key }}
136+
137+
- name: Build release binary
138+
run: cargo +nightly build --release --target ${{ matrix.target }} -p cortex-cli
139+
env:
140+
RUSTFLAGS: "-Zthreads=32"
141+
CARGO_PROFILE_RELEASE_LTO: thin
142+
143+
- name: Prepare artifact (Unix)
144+
if: runner.os != 'Windows'
145+
run: |
146+
mkdir -p dist
147+
cp target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.ext }} dist/
148+
cd dist
149+
tar -czvf ../${{ matrix.artifact }}.tar.gz *
150+
151+
- name: Prepare artifact (Windows)
152+
if: runner.os == 'Windows'
153+
shell: pwsh
154+
run: |
155+
New-Item -ItemType Directory -Force -Path dist
156+
Copy-Item "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.ext }}" dist/
157+
Compress-Archive -Path dist/* -DestinationPath "${{ matrix.artifact }}.zip"
158+
159+
- name: Upload artifact
160+
uses: actions/upload-artifact@v4
161+
with:
162+
name: ${{ matrix.artifact }}
163+
path: |
164+
${{ matrix.artifact }}.tar.gz
165+
${{ matrix.artifact }}.zip
166+
if-no-files-found: ignore
167+
168+
# ==========================================================================
169+
# Publish to R2 using reusable workflow
170+
# ==========================================================================
171+
publish:
172+
name: Publish to R2
173+
needs: [prepare, build-cli]
174+
if: always() && needs.prepare.result == 'success' && needs.build-cli.result == 'success'
175+
uses: ./.github/workflows/publish-r2.yml
176+
with:
177+
version: ${{ needs.prepare.outputs.version }}
178+
channel: ${{ needs.prepare.outputs.channel }}
179+
release_notes: "Auto-deployed from ${{ github.ref_name }} branch at ${{ github.sha }}"
180+
secrets: inherit

.github/workflows/publish-r2.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
- stable
2020
- beta
2121
- nightly
22+
- dev
2223
default: stable
2324
release_notes:
2425
description: "Brief release notes (optional)"
@@ -181,20 +182,39 @@ jobs:
181182
- name: Upload assets to R2
182183
run: |
183184
VERSION="${{ inputs.version }}"
185+
CHANNEL="${{ inputs.channel }}"
184186
185187
for platform in linux-x86_64 linux-aarch64 darwin-x86_64 darwin-aarch64; do
186-
echo "Uploading $platform..."
188+
echo "Uploading $platform version $VERSION..."
187189
rclone copy "dist/$platform/cortex.tar.gz" "r2:cortex-software/assets/$platform/$VERSION/" --progress
188190
rclone copy "dist/$platform/cortex.tar.gz.sha256" "r2:cortex-software/assets/$platform/$VERSION/" --progress
189191
done
190192
191193
# Temporarily disabled: Windows ARM64 build has LLVM/clang issues
192194
for platform in windows-x86_64; do
193-
echo "Uploading $platform..."
195+
echo "Uploading $platform version $VERSION..."
194196
rclone copy "dist/$platform/cortex.zip" "r2:cortex-software/assets/$platform/$VERSION/" --progress
195197
rclone copy "dist/$platform/cortex.zip.sha256" "r2:cortex-software/assets/$platform/$VERSION/" --progress
196198
done
197199
200+
- name: Upload latest symlink assets to R2
201+
run: |
202+
CHANNEL="${{ inputs.channel }}"
203+
204+
# Upload to {platform}/{channel}/latest/ path for easy access to latest build
205+
for platform in linux-x86_64 linux-aarch64 darwin-x86_64 darwin-aarch64; do
206+
echo "Uploading $platform to $CHANNEL/latest..."
207+
rclone copy "dist/$platform/cortex.tar.gz" "r2:cortex-software/assets/$platform/$CHANNEL/latest/" --progress
208+
rclone copy "dist/$platform/cortex.tar.gz.sha256" "r2:cortex-software/assets/$platform/$CHANNEL/latest/" --progress
209+
done
210+
211+
# Temporarily disabled: Windows ARM64 build has LLVM/clang issues
212+
for platform in windows-x86_64; do
213+
echo "Uploading $platform to $CHANNEL/latest..."
214+
rclone copy "dist/$platform/cortex.zip" "r2:cortex-software/assets/$platform/$CHANNEL/latest/" --progress
215+
rclone copy "dist/$platform/cortex.zip.sha256" "r2:cortex-software/assets/$platform/$CHANNEL/latest/" --progress
216+
done
217+
198218
- name: Install jq
199219
run: sudo apt-get update && sudo apt-get install -y jq
200220

@@ -255,7 +275,7 @@ jobs:
255275
# Try to download existing manifest, create empty one if not found
256276
rclone copy "r2:cortex-software/releases/manifest.json" . 2>/dev/null || true
257277
if [ ! -f manifest.json ]; then
258-
echo '{"stable":null,"beta":null,"nightly":null,"all_versions":[]}' > manifest.json
278+
echo '{"stable":null,"beta":null,"nightly":null,"dev":null,"all_versions":[]}' > manifest.json
259279
fi
260280
261281
RELEASE_JSON=$(cat release.json)
@@ -280,7 +300,12 @@ jobs:
280300
echo "| Channel | ${{ inputs.channel }} |" >> $GITHUB_STEP_SUMMARY
281301
echo "| Source Run | [${{ inputs.release_run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ inputs.release_run_id }}) |" >> $GITHUB_STEP_SUMMARY
282302
echo "" >> $GITHUB_STEP_SUMMARY
283-
echo "### Download URLs" >> $GITHUB_STEP_SUMMARY
303+
echo "### Versioned Download URLs" >> $GITHUB_STEP_SUMMARY
284304
echo "- Linux x64: https://software.cortex.foundation/v1/assets/linux-x86_64/${{ inputs.version }}/cortex.tar.gz" >> $GITHUB_STEP_SUMMARY
285305
echo "- macOS ARM64: https://software.cortex.foundation/v1/assets/darwin-aarch64/${{ inputs.version }}/cortex.tar.gz" >> $GITHUB_STEP_SUMMARY
286306
echo "- Windows x64: https://software.cortex.foundation/v1/assets/windows-x86_64/${{ inputs.version }}/cortex.zip" >> $GITHUB_STEP_SUMMARY
307+
echo "" >> $GITHUB_STEP_SUMMARY
308+
echo "### Latest by Channel URLs" >> $GITHUB_STEP_SUMMARY
309+
echo "- Linux x64: https://software.cortex.foundation/v1/assets/linux-x86_64/${{ inputs.channel }}/latest/cortex.tar.gz" >> $GITHUB_STEP_SUMMARY
310+
echo "- macOS ARM64: https://software.cortex.foundation/v1/assets/darwin-aarch64/${{ inputs.channel }}/latest/cortex.tar.gz" >> $GITHUB_STEP_SUMMARY
311+
echo "- Windows x64: https://software.cortex.foundation/v1/assets/windows-x86_64/${{ inputs.channel }}/latest/cortex.zip" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)