-
-
Notifications
You must be signed in to change notification settings - Fork 29
184 lines (157 loc) · 5.33 KB
/
cd.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
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
183
184
name: CD # Continuous Deployment
on:
push:
tags:
- '[v]?[0-9]+.[0-9]+.[0-9]+'
jobs:
publish:
name: Publishing for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
env:
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUSTFLAGS: -C target-feature=+sse2
permissions:
contents: write
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
binary-postfix: ""
binary-name: rainfrog
use-cross: false
features: default
- os: macos-latest
target: aarch64-apple-darwin
binary-postfix: ""
use-cross: false
binary-name: rainfrog
features: default
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary-postfix: ""
use-cross: false
binary-name: rainfrog
features: default
- os: windows-latest
target: x86_64-pc-windows-msvc
binary-postfix: ".exe"
use-cross: false
binary-name: rainfrog
features: default
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
binary-postfix: ""
use-cross: true
binary-name: rainfrog
features: default
- os: ubuntu-latest
target: i686-unknown-linux-gnu
binary-postfix: ""
use-cross: true
binary-name: rainfrog
features: default
- os: ubuntu-latest
target: i686-unknown-linux-musl
binary-postfix: ""
use-cross: true
binary-name: rainfrog
features: default
- os: ubuntu-latest
target: aarch64-linux-android
binary-postfix: ""
use-cross: true
binary-name: rainfrog
features: termux --no-default-features
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Cross build
if: ${{ matrix.use-cross == true }}
uses: houseabsolute/actions-rust-cross@v0
with:
command: build
target: ${{ matrix.target }}
args: "--release --features ${{ matrix.features }}"
cross-version: 7b79041c9278769eca57fae10c74741f5aa5c14b
- name: Cargo build
if: ${{ matrix.use-cross != true }}
uses: actions-rs/cargo@v1
with:
command: build
toolchain: stable
args: --release --target ${{ matrix.target }} --features ${{ matrix.features }}
- name: install strip command
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
shell: bash
run: |
sudo apt update
sudo apt-get install -y binutils-aarch64-linux-gnu
- name: Strip binary
if: ${{ matrix.target != 'aarch64-linux-android' }}
shell: bash
run: |
cd target/${{ matrix.target }}/release
####### reduce binary size by removing debug symbols #######
BINARY_NAME=${{ matrix.binary-name }}${{ matrix.binary-postfix }}
if [[ ${{ matrix.target }} == aarch64-unknown-linux-gnu ]]; then
GCC_PREFIX="aarch64-linux-gnu-"
else
GCC_PREFIX=""
fi
"$GCC_PREFIX"strip $BINARY_NAME
cd ../../../
- name: Packaging final binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
########## create tar.gz ##########
BINARY_NAME=${{ matrix.binary-name }}${{ matrix.binary-postfix }}
RELEASE_NAME=${{ matrix.binary-name }}-${GITHUB_REF/refs\/tags\//}-${{ matrix.target }}
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
########## create sha256 ##########
if [[ ${{ runner.os }} == 'Windows' ]]; then
certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256
else
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
fi
- name: Releasing assets
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
files: |
target/${{ matrix.target }}/release/${{ matrix.binary-name }}-*.tar.gz
target/${{ matrix.target }}/release/${{ matrix.binary-name }}-*.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-cargo:
name: Publishing to Cargo
runs-on: ubuntu-latest
needs: publish
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
release-commenter:
name: Commenting on Issues and PRs
runs-on: ubuntu-latest
needs: publish-cargo
permissions:
pull-requests: write
issues: write
steps:
- uses: apexskier/github-release-commenter@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}