-
Notifications
You must be signed in to change notification settings - Fork 202
223 lines (199 loc) · 7.58 KB
/
Copy pathcli-package-manual.yml
File metadata and controls
223 lines (199 loc) · 7.58 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
name: CLI Package Manual
on:
workflow_dispatch:
inputs:
platform:
description: "Platform to build."
required: true
default: linux-arm64
type: choice
options:
- linux-arm64
- linux-x64
- macos-arm64
- macos-x64
- windows-x64
- all
ubuntu_version:
description: "Ubuntu runner baseline for Linux builds. Ignored for macOS and Windows."
required: true
default: "22.04"
type: choice
options:
- "22.04"
- "24.04"
ref_name:
description: "Branch, tag, or commit SHA to build. Leave empty to use the selected workflow ref."
required: false
type: string
permissions:
contents: read
concurrency:
group: cli-package-manual-${{ inputs.platform }}-${{ inputs.ubuntu_version }}-${{ inputs.ref_name || github.ref }}
cancel-in-progress: true
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
short_sha: ${{ steps.meta.outputs.short_sha }}
checkout_ref: ${{ steps.meta.outputs.checkout_ref }}
matrix: ${{ steps.meta.outputs.matrix }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.ref_name != '' && inputs.ref_name || github.ref }}
fetch-depth: 0
- name: Resolve build metadata
id: meta
shell: bash
env:
INPUT_PLATFORM: ${{ inputs.platform }}
INPUT_UBUNTU_VERSION: ${{ inputs.ubuntu_version }}
INPUT_REF_NAME: ${{ inputs.ref_name }}
run: |
set -euo pipefail
VERSION="$(jq -r '.version' package.json)"
FULL_SHA="$(git rev-parse HEAD)"
SHORT_SHA="$(git rev-parse --short HEAD)"
CHECKOUT_REF="$FULL_SHA"
case "${INPUT_UBUNTU_VERSION}" in
22.04)
LINUX_X64_RUNNER="ubuntu-22.04"
LINUX_ARM64_RUNNER="ubuntu-22.04-arm"
LINUX_NAME_SUFFIX="ubuntu2204"
;;
24.04)
LINUX_X64_RUNNER="ubuntu-24.04"
LINUX_ARM64_RUNNER="ubuntu-24.04-arm"
LINUX_NAME_SUFFIX="ubuntu2404"
;;
*)
echo "Unsupported ubuntu_version: ${INPUT_UBUNTU_VERSION}" >&2
exit 1
;;
esac
case "${INPUT_PLATFORM}" in
linux-arm64)
MATRIX="{\"platform\":[{\"os\":\"${LINUX_ARM64_RUNNER}\",\"name\":\"linux-arm64-${LINUX_NAME_SUFFIX}\",\"target\":\"aarch64-unknown-linux-gnu\"}]}"
;;
linux-x64)
MATRIX="{\"platform\":[{\"os\":\"${LINUX_X64_RUNNER}\",\"name\":\"linux-x64-${LINUX_NAME_SUFFIX}\",\"target\":\"x86_64-unknown-linux-gnu\"}]}"
;;
macos-arm64)
MATRIX='{"platform":[{"os":"macos-15","name":"macos-arm64","target":"aarch64-apple-darwin"}]}'
;;
macos-x64)
MATRIX='{"platform":[{"os":"macos-15-intel","name":"macos-x64","target":"x86_64-apple-darwin"}]}'
;;
windows-x64)
MATRIX='{"platform":[{"os":"windows-latest","name":"windows-x64","target":"x86_64-pc-windows-msvc"}]}'
;;
all)
MATRIX="{\"platform\":[{\"os\":\"macos-15\",\"name\":\"macos-arm64\",\"target\":\"aarch64-apple-darwin\"},{\"os\":\"macos-15-intel\",\"name\":\"macos-x64\",\"target\":\"x86_64-apple-darwin\"},{\"os\":\"${LINUX_X64_RUNNER}\",\"name\":\"linux-x64-${LINUX_NAME_SUFFIX}\",\"target\":\"x86_64-unknown-linux-gnu\"},{\"os\":\"${LINUX_ARM64_RUNNER}\",\"name\":\"linux-arm64-${LINUX_NAME_SUFFIX}\",\"target\":\"aarch64-unknown-linux-gnu\"},{\"os\":\"windows-latest\",\"name\":\"windows-x64\",\"target\":\"x86_64-pc-windows-msvc\"}]}"
;;
*)
echo "Unsupported platform: ${INPUT_PLATFORM}" >&2
exit 1
;;
esac
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
echo "checkout_ref=$CHECKOUT_REF" >> "$GITHUB_OUTPUT"
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
build:
name: Build (${{ matrix.platform.name }})
runs-on: ${{ matrix.platform.os }}
needs: prepare
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ needs.prepare.outputs.checkout_ref }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.14"
- name: Build plugin Host resources
run: |
bun install --cwd src/apps/extension-host --frozen-lockfile
bun run --cwd src/apps/extension-host build
- name: Install Linux system dependencies
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
pkg-config \
build-essential \
libxcb1-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Cache Rust build
uses: swatinem/rust-cache@v2
with:
shared-key: "cli-manual-v1-${{ matrix.platform.name }}"
cache-bin: false
- name: Build CLI (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
cargo build --release \
--target ${{ matrix.platform.target }} \
-p bitfun-cli
- name: Build CLI (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
RUSTFLAGS: -C target-feature=+crt-static
run: cargo build --release --target ${{ matrix.platform.target }} -p bitfun-cli
- name: Test installer (Unix)
if: runner.os != 'Windows'
shell: bash
env:
CARGO_BUILD_TARGET: ${{ matrix.platform.target }}
run: bash scripts/cli/test-install-unix.sh "${{ matrix.platform.target }}"
- name: Test installer (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
CARGO_BUILD_TARGET: ${{ matrix.platform.target }}
RUSTFLAGS: -C target-feature=+crt-static
run: ./scripts/cli/test-install-windows.ps1 -Target $env:CARGO_BUILD_TARGET
- name: Package and smoke test (Unix)
if: runner.os != 'Windows'
id: stage
shell: bash
env:
VERSION: ${{ needs.prepare.outputs.version }}
TARGET: ${{ matrix.platform.target }}
run: |
set -euo pipefail
bash scripts/cli/package-unix.sh "$VERSION" "$TARGET"
- name: Package and smoke test (Windows)
if: runner.os == 'Windows'
id: stage-windows
shell: pwsh
env:
VERSION: ${{ needs.prepare.outputs.version }}
TARGET: ${{ matrix.platform.target }}
run: |
./scripts/cli/package-windows.ps1 -Version $env:VERSION -Target $env:TARGET
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: bitfun-cli-${{ needs.prepare.outputs.version }}-${{ needs.prepare.outputs.short_sha }}-${{ matrix.platform.name }}
if-no-files-found: error
path: |
${{ steps.stage.outputs.archive || steps.stage-windows.outputs.archive }}
${{ steps.stage.outputs.checksum || steps.stage-windows.outputs.checksum }}