Repository navigation
124 lines (107 loc) · 4.09 KB
/
Copy pathcli-binary.yml
File metadata and controls
124 lines (107 loc) · 4.09 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
name: CLI Binary
# Runs after merge, not on PRs: it is a full macOS release build plus app
# bundle, and macOS runners are the scarcest.
on:
push:
branches: [main]
paths:
- "src-tauri/src/lib.rs"
- "src-tauri/Cargo.toml"
- "src-tauri/build.rs"
- ".github/workflows/cli-binary.yml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
detect-rust-changes:
timeout-minutes: 15
name: detect rust changes
runs-on: ubuntu-22.04
outputs:
rust_changed: ${{ steps.filter.outputs.rust }}
steps:
- uses: actions/checkout@v5
- name: Check for src-tauri changes
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
filters: |
rust:
- "src-tauri/**"
sandboxed-cli:
name: Sandboxed macOS CLI
needs: detect-rust-changes
if: needs.detect-rust-changes.outputs.rust_changed == 'true'
runs-on: macos-latest
# Main-only, and it saves the cache the next run restores, so it gets
# room for a cold release build (over 20 minutes).
timeout-minutes: 35
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "24"
cache: npm
cache-dependency-path: package-lock.json
- name: Install Rust stable
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1
with:
toolchain: stable
# The workspace root (not src-tauri/) owns target/.
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
shared-key: cli-macos
workspaces: |
. -> target
# The Tauri CLI that packages the app below.
- name: Install dependencies
run: npm ci
- name: Build release CLI binary
run: cargo build --release --locked --bin treq --target aarch64-apple-darwin
- name: Run CLI with filesystem writes denied
run: |
sandbox-exec \
-p '(version 1) (allow default) (deny file-write*)' \
target/aarch64-apple-darwin/release/treq --help > "$RUNNER_TEMP/treq-help.txt"
grep -F "Treq - Stacking ADE" "$RUNNER_TEMP/treq-help.txt"
grep -F "Usage: treq" "$RUNNER_TEMP/treq-help.txt"
- name: Build and verify packaged app
run: |
npm run tauri build -- --target aarch64-apple-darwin --bundles app
codesign --force --deep --sign - target/aarch64-apple-darwin/release/bundle/macos/Treq.app
bash scripts/verify-macos-bundle.sh target/aarch64-apple-darwin/release/bundle/macos/Treq.app
headless-linux-cli:
name: Headless Linux CLI
needs: detect-rust-changes
if: needs.detect-rust-changes.outputs.rust_changed == 'true'
runs-on: ubuntu-22.04
timeout-minutes: 35
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1
with:
toolchain: stable
targets: x86_64-unknown-linux-musl
- name: Install musl
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
cache-on-failure: true
workspaces: |
./src-tauri -> target
key: musl
# Same build as the release's linux-cli job, without the webkit/gtk
# packages: the build fails if a desktop dependency leaks back in.
- name: Build headless CLI
run: |
sed -i 's/^crate-type = .*/crate-type = ["rlib"]/' src-tauri/Cargo.toml
cargo build --release --locked --no-default-features --bin treq --target x86_64-unknown-linux-musl
- name: Run CLI in Alpine
run: |
docker run --rm -v "$PWD/target/x86_64-unknown-linux-musl/release/treq:/usr/local/bin/treq:ro" \
alpine:3.20 treq --help | grep -F "Usage: treq"