Repository navigation
124 lines (108 loc) · 3.5 KB
/
Copy pathrelease.yml
File metadata and controls
124 lines (108 loc) · 3.5 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: release
# 构建 6 个平台的产物并挂到 GitHub Release(推送 v* tag 触发)。
#
# 为什么是这个形状:
# * 依赖全部是纯 Rust(iced-x86 + memmap2),没有 C/系统库,所以交叉编译
# 只需一个工具链:Linux arm64 走 `cross`(Docker),Windows arm64 用 MSVC
# 的 amd64_arm64 交叉工具,macOS 一个 arm runner 同时产出两个架构。
# * arm64 交叉产物只构建、不测试(runner 无 arm 硬件跑 x64);x64 原生构建+测试。
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc
os: windows-latest
cross: false
test: true
- target: aarch64-pc-windows-msvc
os: windows-latest
cross: false
test: false
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cross: false
test: true
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
test: false
- target: aarch64-apple-darwin
os: macos-latest
cross: false
test: true
- target: x86_64-apple-darwin
os: macos-latest
cross: false
test: false
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
# Windows ARM64:默认 MSVC dev shell 是 x64,切到 ARM64 交叉工具,
# 否则 cc/link 找不到正确的 cl.exe 与库。
- name: Set up MSVC (Windows ARM64)
if: matrix.target == 'aarch64-pc-windows-msvc'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64_arm64
- name: Install cross
if: matrix.cross
run: cargo install cross --locked
- name: Build (native)
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }}
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Test (x64 only)
if: matrix.test
run: cargo test --release --target ${{ matrix.target }}
- name: Stage artifact
shell: bash
run: |
set -euo pipefail
out="signscanner-${{ matrix.target }}"
if [[ "${{ matrix.target }}" == *windows* ]]; then
cp "target/${{ matrix.target }}/release/signscanner.exe" "${out}.exe"
else
cp "target/${{ matrix.target }}/release/signscanner" "${out}"
fi
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: signscanner-${{ matrix.target }}
path: signscanner-${{ matrix.target }}*
if-no-files-found: error
release:
name: publish release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true