-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (145 loc) · 5.09 KB
/
build.yaml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Build and release mrxbuilder
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
strategy:
matrix:
target:
- name: x86_64-windows
triple: x86_64-pc-windows-msvc
extension: .exe
runner: windows-latest
- name: x86_64-linux-musl
triple: x86_64-unknown-linux-musl
extension: ""
runner: ubuntu-latest
- name: x86_64-macos
triple: x86_64-apple-darwin
extension: ""
runner: macos-latest
runs-on: ${{ matrix.target.runner }}
steps:
- uses: actions/checkout@v3
- name: Cache Cargo dependencies
uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ matrix.target.triple }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ matrix.target.triple }}-cargo-
- name: Cache build artifacts
uses: actions/cache@v3
with:
path: target
key: ${{ matrix.target.triple }}-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ matrix.target.triple }}-target-
- name: Install nasm
uses: ilammy/setup-nasm@v1
- name: Install musl build dependencies
if: matrix.target.name == 'x86_64-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Install musl target
if: matrix.target.name == 'x86_64-linux-musl'
run: rustup target add ${{ matrix.target.triple }}
- name: Build binary
run: cargo build --profile ci --target ${{ matrix.target.triple }}
- name: Install cargo-get
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-get
- name: Get version
id: get_version
shell: bash
run: echo "version=$(cargo get version)" >> "$GITHUB_OUTPUT"
- name: Copy binary
shell: bash
run: |
cp target/${{ matrix.target.triple }}/ci/mrxbuilder${{ matrix.target.extension }} \
mrxbuilder-v${{ steps.get_version.outputs.version }}-${{ matrix.target.name }}${{ matrix.target.extension }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target.name }}
path: mrxbuilder-v${{ steps.get_version.outputs.version }}-${{ matrix.target.name }}${{ matrix.target.extension }}
test:
strategy:
matrix:
runner:
- ubuntu-latest
- macos-latest
- windows-latest
needs: build
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v3
- name: Download built binaries
uses: actions/download-artifact@v3
with:
path: binaries
- name: Run the builder
if: matrix.runner == 'ubuntu-latest'
run: |
chmod +x ./binaries/x86_64-linux-musl/mrxbuilder-v*-x86_64-linux-musl
./binaries/x86_64-linux-musl/mrxbuilder-v*-x86_64-linux-musl ./sample-input/index.toml ./out debug,release,metadata
echo
tree out
du -sh out
- name: Run the builder
if: matrix.runner == 'macos-latest'
run: |
chmod +x ./binaries/x86_64-macos/mrxbuilder-v*-x86_64-macos
./binaries/x86_64-macos/mrxbuilder-v*-x86_64-macos ./sample-input/index.toml ./out debug,release,metadata
- name: Run the builder
if: matrix.runner == 'windows-latest'
run: |
./binaries/x86_64-windows/mrxbuilder-v*-x86_64-windows.exe ./sample-input/index.toml ./out debug,release,metadata
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: out-${{ matrix.runner }}
path: out
publish-draft-release:
needs: test
runs-on: ubuntu-latest
# Only run this job on manual trigger
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
- name: Download built binaries
uses: actions/download-artifact@v3
with:
path: binaries
- name: Install latest upx
uses: crazy-max/ghaction-upx@v2
with:
install-only: true
- name: Install cargo-get
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-get
- name: Get version
id: get_version
run: echo "version=$(cargo get version)" >> "$GITHUB_OUTPUT"
- name: Pack binaries
run: |
mkdir -p release
for target in x86_64-linux-musl x86_64-windows x86_64-macos; do
mv binaries/$target/mrxbuilder-v*-$target* .
file=mrxbuilder-v*-$target*
chmod +x $file
upx --best $file
zip mrxbuilder-v${{ steps.get_version.outputs.version }}-$target.zip $file README.md LICENSE
done
- name: Create draft release
uses: softprops/action-gh-release@v1
with:
files: "*.zip"
tag_name: v${{ steps.get_version.outputs.version }}
name: mrxbuilder v${{ steps.get_version.outputs.version }}
draft: true