-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (145 loc) · 4.93 KB
/
Copy pathrelease.yml
File metadata and controls
161 lines (145 loc) · 4.93 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
validate:
name: Validate Tag
runs-on: ubuntu-latest
outputs:
is_prerelease: ${{ steps.check.outputs.is_prerelease }}
steps:
- name: Validate Tag Format and Pre-release Status
id: check
shell: bash
run: |
TAG="${GITHUB_REF_NAME}"
if [[ ! "${TAG}" =~ ^v[0-9]+\.[0-9]+\.0(-alpha|-beta)?$ ]]; then
echo "Error: Tag '${TAG}' does not match required format (vX.Y.0, vX.Y.0-alpha, vX.Y.0-beta)."
exit 1
fi
if [[ "${TAG}" =~ -(alpha|beta)$ ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi
build:
name: Build (${{ matrix.target }})
needs: validate
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
asset_name: ArkCode-linux-x86_64
use_cross: true
- target: aarch64-unknown-linux-musl
runner: ubuntu-latest
asset_name: ArkCode-linux-aarch64
use_cross: true
- target: x86_64-pc-windows-msvc
runner: windows-latest
asset_name: ArkCode-windows-x86_64.exe
use_cross: false
- target: aarch64-pc-windows-msvc
runner: windows-latest
asset_name: ArkCode-windows-aarch6464.exe
use_cross: false
- target: aarch64-apple-darwin
runner: macos-latest
asset_name: ArkCode-macos-aarch64
use_cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Enable Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross
if: matrix.use_cross
shell: bash
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install Linux Cross Stripping Tools
if: matrix.target == 'aarch64-unknown-linux-musl'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y binutils-aarch64-linux-gnu
- name: Build release binary
shell: bash
env:
RUSTFLAGS: "-C strip=symbols"
run: |
if [ "${{ matrix.use_cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Strip binary
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-musl" ]; then
aarch64-linux-gnu-strip "target/${{ matrix.target }}/release/arkcode"
else
strip "target/${{ matrix.target }}/release/arkcode"
fi
elif [ "${{ runner.os }}" = "macOS" ]; then
strip "target/${{ matrix.target }}/release/arkcode"
elif [ "${{ runner.os }}" = "Windows" ]; then
echo "Windows MSVC binary stripped via rustc RUSTFLAGS strip=symbols"
fi
- name: Prepare artifact
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
mv "target/${{ matrix.target }}/release/arkcode.exe" "${{ matrix.asset_name }}"
else
mv "target/${{ matrix.target }}/release/arkcode" "${{ matrix.asset_name }}"
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}
if-no-files-found: error
release:
name: Create GitHub Release
needs: [validate, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Generate SHA256SUMS
shell: bash
run: |
cd artifacts
sha256sum ArkCode-linux-x86_64 ArkCode-linux-aarch64 ArkCode-windows-x86_64.exe ArkCode-windows-aarch6464.exe ArkCode-macos-aarch64 | sort -k2 > SHA256SUMS
cat SHA256SUMS
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/ArkCode-linux-x86_64
artifacts/ArkCode-linux-aarch64
artifacts/ArkCode-windows-x86_64.exe
artifacts/ArkCode-windows-aarch6464.exe
artifacts/ArkCode-macos-aarch64
artifacts/SHA256SUMS
prerelease: ${{ needs.validate.outputs.is_prerelease == 'true' }}
generate_release_notes: true