-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (119 loc) · 3.88 KB
/
create-release.yml
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
name: Create release
run-name: Create release for tag ${{ github.ref_name }}
on:
push:
tags:
- v**
env:
PROJECT_NAME: "outlaw-format"
jobs:
build-release:
strategy:
fail-fast: false
matrix:
include:
# Linux
- build: linux-gnu
os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-gnu
binary_extension:
- build: linux-musl
os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-musl
binary_extension:
- build: linux-arm
os: ubuntu-22.04
rust: stable
target: arm-unknown-linux-gnueabihf
binary_extension:
# macOS
- build: macos
os: macos-12
rust: stable
target: x86_64-apple-darwin
binary_extension:
# Windows
- build: win-gnu
os: windows-2022
rust: stable-x86_64-gnu
target: x86_64-pc-windows-gnu
binary_extension: .exe
- build: win-msvc
os: windows-2022
rust: stable
target: x86_64-pc-windows-msvc
binary_extension: .exe
- build: win32-msvc
os: windows-2022
rust: stable
target: i686-pc-windows-msvc
binary_extension: .exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install prerequisites
shell: bash
run: |
case "${{ matrix.target }}" in
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}-${{ matrix.target }}-${{ matrix.rust }}
- name: Set cargo command
shell: bash
run: echo "CARGO=cargo" >> $GITHUB_ENV
- name: Install Cross
if: "!startsWith(matrix.build, 'win')"
shell: bash
run: |
cargo install --bins cross
echo "CARGO=cross" >> $GITHUB_ENV
- name: Set environment variables related to compilation
shell: bash
run: |
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}/release" >> $GITHUB_ENV
- name: Build release binary for ${{ matrix.target }}
shell: bash
run: ${{ env.CARGO }} build --release --verbose $TARGET_FLAGS
- name: List files
shell: bash
run: find . -type f
- name: Set binary paths
shell: bash
run: |
echo "BINARY_SRC_PATH=${{ env.TARGET_DIR }}/${{ env.PROJECT_NAME }}${{ matrix.binary_extension }}" >> $GITHUB_ENV
echo "BINARY_DEST_PATH=${{ env.TARGET_DIR }}/${{ env.PROJECT_NAME }}-${{ matrix.target }}${{ matrix.binary_extension }}" >> $GITHUB_ENV
- name: Rename binary
shell: bash
run: |
mv "${{ env.BINARY_SRC_PATH }}" "${{ env.BINARY_DEST_PATH }}"
- name: Strip release binary
shell: bash
run: |
STRIP="strip"
case ${{ matrix.target }} in
arm-unknown-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;
*-pc-windows-*) STRIP="" ;;
esac;
if [ -n "${STRIP}" ]; then
"${STRIP}" "${{ env.BINARY_DEST_PATH }}"
fi
- name: List files
shell: bash
run: find . -type f
- name: Upload release binary
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.BINARY_DEST_PATH }}