-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (103 loc) · 3.19 KB
/
Copy pathrelease.yml
File metadata and controls
122 lines (103 loc) · 3.19 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: windows-x86_64
os: windows-latest
artifact: ii-windows-x86_64.exe
binary: target/release/ii.exe
- name: linux-x86_64
os: ubuntu-latest
artifact: ii-linux-x86_64
binary: target/x86_64-unknown-linux-musl/release/ii
- name: macos-aarch64
os: macos-latest
artifact: ii-macos-aarch64
binary: target/release/ii
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Linux musl toolchain
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
rustup target add x86_64-unknown-linux-musl
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Test
run: cargo test --locked
- name: Build Linux static release
if: runner.os == 'Linux'
shell: bash
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: musl-gcc
CC_x86_64_unknown_linux_musl: musl-gcc
run: cargo build --release --locked --target x86_64-unknown-linux-musl
- name: Verify Linux binary is statically linked
if: runner.os == 'Linux'
shell: bash
run: file "${{ matrix.binary }}" | grep -Eq 'statically linked|static-pie linked'
- name: Build release
if: runner.os != 'Linux'
run: cargo build --release --locked
- name: Compress Windows binary with bundled UPX
if: runner.os == 'Windows'
shell: pwsh
run: |
.\upx-5.1.0-win64\upx.exe --best --lzma "${{ matrix.binary }}"
- name: Install UPX on Linux
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y upx-ucl || sudo apt-get install -y upx
- name: Compress Linux ELF with UPX
if: runner.os == 'Linux'
shell: bash
run: |
upx --best --lzma "${{ matrix.binary }}"
- name: Prepare Windows artifact
if: runner.os == 'Windows'
shell: pwsh
run: |
Copy-Item "${{ matrix.binary }}" "${{ matrix.artifact }}"
- name: Prepare Unix artifact
if: runner.os != 'Windows'
shell: bash
run: |
cp "${{ matrix.binary }}" "${{ matrix.artifact }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ matrix.artifact }}
release:
name: Publish GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
generate_release_notes: true