-
-
Notifications
You must be signed in to change notification settings - Fork 65
158 lines (142 loc) · 4.62 KB
/
Copy pathbuild.yml
File metadata and controls
158 lines (142 loc) · 4.62 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
name: Build
on:
workflow_call:
inputs:
release:
description: "Release tag or identifier"
required: true
type: string
ref:
description: "Git ref to build from"
required: false
type: string
default: ""
permissions:
contents: write
issues: read
actions: read
jobs:
build:
name: Build for ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
CARGO: cargo
strategy:
matrix:
name:
- linux-x86-gnu
- linux-x86-musl
- linux-arm-gnu
- linux-arm-musl
- macos-x86
- macos-arm
- macos-universal
- windows-x86
- windows-arm
include:
- name: linux-x86-gnu
os: ubuntu-latest
family: linux
arch: x86_64
target: x86_64-unknown-linux-gnu
archiver: tar.gz
asset: hl-linux-x86_64-gnu.tar.gz
- name: linux-x86-musl
os: ubuntu-latest
family: linux
arch: x86_64
target: x86_64-unknown-linux-musl
archiver: tar.gz
asset: hl-linux-x86_64-musl.tar.gz
cross: true
- name: linux-arm-gnu
os: ubuntu-latest
family: linux
arch: aarch64
target: aarch64-unknown-linux-gnu
archiver: tar.gz
asset: hl-linux-arm64-gnu.tar.gz
cross: true
- name: linux-arm-musl
os: ubuntu-latest
family: linux
arch: aarch64
target: aarch64-unknown-linux-musl
archiver: tar.gz
asset: hl-linux-arm64-musl.tar.gz
cross: true
- name: macos-x86
os: macos-latest
family: macos
arch: x86_64
target: x86_64-apple-darwin
archiver: tar.gz
asset: hl-macos-x86_64.tar.gz
- name: macos-arm
os: macos-latest
family: macos
arch: aarch64
target: aarch64-apple-darwin
archiver: tar.gz
asset: hl-macos-arm64.tar.gz
- name: macos-universal
os: macos-latest
family: macos
arch: "{aarch64,x86_64}"
target: "{aarch64,x86_64}-apple-darwin"
archiver: tar.gz
asset: hl-macos.tar.gz
universal: true
- name: windows-x86
os: windows-latest
family: windows
arch: x86_64
target: x86_64-pc-windows-msvc
archiver: 7z
asset: hl-windows.zip
- name: windows-arm
os: windows-latest
family: windows
arch: aarch64
target: aarch64-pc-windows-msvc
archiver: 7z
asset: hl-windows-arm64.zip
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref || github.ref }}
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
toolchain: stable
rustflags: ""
- name: Install Cross
if: matrix.cross
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
- name: Add Target
if: matrix.cross == false && matrix.target != ''
run: |
rustup target add ${{ matrix.target }}
- name: Build
run: echo ${{ matrix.target }} | xargs -n 1 ${{ env.CARGO }} build --release --locked --verbose --target
- name: Sign
if: matrix.family == 'macos'
run: codesign --force --deep --sign - ./target/${{ matrix.target }}/release/hl
- name: Package using `tar`
if: matrix.archiver == 'tar.gz' && matrix.universal == false
run: tar -C ./target/${{ matrix.target }}/release -cz -f ${{ matrix.asset }} hl
- name: Package using `7z`
if: matrix.archiver == '7z' && matrix.universal == false
run: 7z a ${{ matrix.asset }} .\target\${{ matrix.target }}\release\hl.exe
- name: Make universal binary
if: matrix.family == 'macos' && matrix.universal == true
run: lipo ./target/${{ matrix.target }}/release/hl -create -output ./target/hl
- name: Package universal binary using `tar`
if: matrix.archiver == 'tar.gz' && matrix.universal == true
run: tar -C ./target -cz -f ${{ matrix.asset }} hl
- name: Upload binaries to release
run: |
gh release upload "${{ inputs.release }}" "${{ matrix.asset }}" --clobber
env:
GH_TOKEN: ${{ github.token }}