-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (109 loc) · 4.49 KB
/
Copy pathbuild.yml
File metadata and controls
124 lines (109 loc) · 4.49 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: Build Binaries (Reusable)
on:
workflow_call:
inputs:
version_name:
description: 'Version identifier (e.g., v1.0.0 or nightly-abc1234)'
required: true
type: string
is_nightly:
description: 'Whether this is a nightly build'
required: false
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build qmtui for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# ─── Linux (Static MUSL) ──────────────────────────────────────────
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
bin_name: qmtui
archive_ext: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
bin_name: qmtui
archive_ext: tar.gz
# ─── macOS ────────────────────────────────────────────────────────
- os: macos-14
target: x86_64-apple-darwin
bin_name: qmtui
archive_ext: tar.gz
- os: macos-14
target: aarch64-apple-darwin
bin_name: qmtui
archive_ext: tar.gz
# ─── Windows (Static CRT) ────────────────────────────────────────
- os: windows-latest
target: x86_64-pc-windows-msvc
bin_name: qmtui.exe
archive_ext: zip
rust_flags: "-C target-feature=+crt-static"
- os: windows-latest
target: aarch64-pc-windows-msvc
bin_name: qmtui.exe
archive_ext: zip
rust_flags: "-C target-feature=+crt-static"
# ─── FreeBSD ─────────────────────────────────────────────────────
- os: freebsd
target: x86_64-unknown-freebsd
bin_name: qmtui
archive_ext: tar.gz
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain & targets
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install cross-compilation toolchain
if: runner.os == 'Linux'
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
- name: Cache Cargo dependencies
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
env:
QMTUI_VERSION: ${{ inputs.version_name }}
RUSTFLAGS: ${{ matrix.rust_flags || '' }}
run: cargo build --release --bin qmtui --target ${{ matrix.target }}
- name: Prepare artifact for upload (Linux, macOS & FreeBSD)
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
ARTIFACT_DIR="dist"
PKG="qmtui-${{ inputs.version_name }}-${{ matrix.target }}"
STAGING="$ARTIFACT_DIR/$PKG"
mkdir -p "$STAGING"
cp "target/${{ matrix.target }}/release/${{ matrix.bin_name }}" "$STAGING/"
cp README.md LICENSE "$STAGING/"
tar -czf "$ARTIFACT_DIR/${PKG}.tar.gz" -C "$ARTIFACT_DIR" "$PKG"
echo "ASSET_PATH=$ARTIFACT_DIR/${PKG}.tar.gz" >> $GITHUB_ENV
- name: Prepare artifact for upload (Windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$ARTIFACT_DIR = "dist"
$PKG = "qmtui-${{ inputs.version_name }}-${{ matrix.target }}"
$STAGING = Join-Path $ARTIFACT_DIR $PKG
New-Item -ItemType Directory -Force -Path $STAGING
Copy-Item "target/${{ matrix.target }}/release/${{ matrix.bin_name }}" -Destination $STAGING
Copy-Item README.md, LICENSE -Destination $STAGING
$ZIP_PATH = "$ARTIFACT_DIR/${PKG}.zip"
Compress-Archive -Path (Join-Path $STAGING '*') -DestinationPath $ZIP_PATH -Force
echo "ASSET_PATH=${ZIP_PATH}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: qmtui-${{ matrix.target }}
path: ${{ env.ASSET_PATH }}