-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (158 loc) · 5.74 KB
/
dev-deploy.yml
File metadata and controls
180 lines (158 loc) · 5.74 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
name: Dev/Beta Deploy to R2
on:
push:
branches:
- beta
- dev
- nightly
env:
BINARY_NAME: Cortex
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: "-Zthreads=32"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
CARGO_INCREMENTAL: 0
permissions:
contents: read
actions: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ==========================================================================
# Prepare - Determine version and channel from branch
# ==========================================================================
prepare:
name: Prepare Build
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
version: ${{ steps.version.outputs.version }}
channel: ${{ steps.version.outputs.channel }}
cache_key: ${{ steps.cache.outputs.key }}
steps:
- uses: actions/checkout@v4
- name: Generate cache key
id: cache
run: |
echo "key=rust-dev-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}" >> $GITHUB_OUTPUT
- name: Determine version and channel
id: version
run: |
# Read base version from VERSION_CLI
BASE_VERSION=$(cat VERSION_CLI | tr -d '\n')
# Get short SHA (7 characters)
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
# Determine channel from branch name
BRANCH="${{ github.ref_name }}"
case "$BRANCH" in
beta)
CHANNEL="beta"
;;
dev)
CHANNEL="dev"
;;
nightly)
CHANNEL="nightly"
;;
*)
echo "ERROR: Unsupported branch '$BRANCH'"
exit 1
;;
esac
# Generate version string: {base_version}-{channel}.{short_sha}
VERSION="${BASE_VERSION}-${CHANNEL}.${SHORT_SHA}"
echo "Base version: $BASE_VERSION"
echo "Channel: $CHANNEL"
echo "Short SHA: $SHORT_SHA"
echo "Full version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
# ==========================================================================
# Build CLI Binaries (32 vCPU for compilation)
# ==========================================================================
build-cli:
name: CLI ${{ matrix.artifact }}
runs-on: ${{ matrix.runner }}
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- runner: blacksmith-32vcpu-ubuntu-2404
target: x86_64-unknown-linux-gnu
artifact: cortex-cli-linux-x64
ext: ""
- runner: blacksmith-32vcpu-ubuntu-2404-arm
target: aarch64-unknown-linux-gnu
artifact: cortex-cli-linux-arm64
ext: ""
- runner: macos-latest
target: x86_64-apple-darwin
artifact: cortex-cli-macos-x64
ext: ""
- runner: macos-latest
target: aarch64-apple-darwin
artifact: cortex-cli-macos-arm64
ext: ""
- runner: blacksmith-32vcpu-windows-2025
target: x86_64-pc-windows-msvc
artifact: cortex-cli-windows-x64
ext: .exe
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: Setup Rust cache (Blacksmith optimized)
if: contains(matrix.runner, 'blacksmith')
uses: useblacksmith/rust-cache@v3
with:
prefix-key: "rust-dev-cli-${{ matrix.target }}"
shared-key: ${{ needs.prepare.outputs.cache_key }}
- name: Setup Rust cache (non-Blacksmith)
if: "!contains(matrix.runner, 'blacksmith')"
uses: Swatinem/rust-cache@v2
with:
prefix-key: "rust-dev-cli-${{ matrix.target }}"
shared-key: ${{ needs.prepare.outputs.cache_key }}
- name: Build release binary
run: cargo +nightly build --release --target ${{ matrix.target }} -p cortex-cli
env:
RUSTFLAGS: "-Zthreads=32"
CARGO_PROFILE_RELEASE_LTO: thin
- name: Prepare artifact (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.ext }} dist/
cd dist
tar -czvf ../${{ matrix.artifact }}.tar.gz *
- name: Prepare artifact (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.ext }}" dist/
Compress-Archive -Path dist/* -DestinationPath "${{ matrix.artifact }}.zip"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
${{ matrix.artifact }}.tar.gz
${{ matrix.artifact }}.zip
if-no-files-found: ignore
# ==========================================================================
# Publish to R2 using reusable workflow
# ==========================================================================
publish:
name: Publish to R2
needs: [prepare, build-cli]
if: always() && needs.prepare.result == 'success' && needs.build-cli.result == 'success'
uses: ./.github/workflows/publish-r2.yml
with:
version: ${{ needs.prepare.outputs.version }}
channel: ${{ needs.prepare.outputs.channel }}
release_notes: "Auto-deployed from ${{ github.ref_name }} branch at ${{ github.sha }}"
secrets: inherit