-
Notifications
You must be signed in to change notification settings - Fork 7
246 lines (212 loc) · 7.2 KB
/
prerelease.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: Prerelease
# IMPORTANT: This workflow utilizes caching for previous build artifacts. In the
# event of a full/partial rebuild, remember to manually remove corresponding
# cache records from the GitHub Actions admin panel.
#
# Benefit of this caching strategy is that it allows for individual cache
# invalidation for each binary
on:
workflow_dispatch:
push:
branches:
- main
- 'ci/**'
tags:
- '[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
env:
release: ${{ startsWith(github.ref, 'refs/tags/') || github.repository == 'gosh-sh/gosh' }}
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
bin:
- git-remote-gosh
- git-remote-gosh_v1_0_0
- git-remote-gosh_v2_0_0
- git-remote-gosh_v3_0_0
- git-remote-gosh_v4_0_0
- git-remote-gosh_v5_0_0
- git-remote-gosh_v5_1_0
- git-remote-gosh_v6_0_0
- git-remote-gosh_v6_1_0
result:
- git-remote-gosh-darwin-arm64
- git-remote-gosh-darwin-amd64
- git-remote-gosh-linux-arm64
- git-remote-gosh-linux-amd64
include:
# targets
- result: git-remote-gosh-darwin-arm64
target: aarch64-apple-darwin
os: macos-12
- result: git-remote-gosh-darwin-amd64
target: x86_64-apple-darwin
os: macos-12
- result: git-remote-gosh-linux-arm64
target: aarch64-unknown-linux-musl
os: ubuntu-22.04
- result: git-remote-gosh-linux-amd64
target: x86_64-unknown-linux-musl
os: ubuntu-22.04
# cargo projects
- bin: git-remote-gosh
dir: gosh-dispatcher
- bin: git-remote-gosh_v1_0_0
dir: v1_x/git-remote-gosh
cache: true
- bin: git-remote-gosh_v2_0_0
dir: v2_x/git-remote-gosh
cache: true
- bin: git-remote-gosh_v3_0_0
dir: v3_x/git-remote-gosh
cache: true
- bin: git-remote-gosh_v4_0_0
dir: v4_x/git-remote-gosh
cache: true
- bin: git-remote-gosh_v5_0_0
dir: v5_x/v5.0.0/git-remote-gosh
cache: true
- bin: git-remote-gosh_v5_1_0
dir: v5_x/v5.1.0/git-remote-gosh
cache: true
- bin: git-remote-gosh_v6_0_0
dir: v6_x/v6.0.0/git-remote-gosh
cache: true
- bin: git-remote-gosh_v6_1_0
dir: v6_x/v6.1.0/git-remote-gosh
env:
CACHE: false # default env value
CACHE_RESULT_DIR: ${{ github.workspace }}/.result/${{ matrix.result }}
CACHE_RESULT_BIN: ${{ github.workspace }}/.result/${{ matrix.result }}/${{ matrix.bin }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set VERSION
id: version
run: |
echo "VERSION=$(cat version.json | jq -r .version)" >> "$GITHUB_OUTPUT"
- name: Setup result cache
uses: actions/cache@v3
with:
path: ${{ env.CACHE_RESULT_DIR }}
key: result-${{ matrix.target }}-${{ matrix.bin }}
- name: Check if can use cache
if: matrix.cache
run: |
if [[ -f ${{ env.CACHE_RESULT_BIN }} ]] ; then
echo "CACHE=true" >> $GITHUB_ENV
fi
- name: Setup cargo cache
if: env.CACHE != 'true'
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: builder-${{ runner.os }}-cargo
- name: Install Rust
if: env.CACHE != 'true'
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux tools
if: env.CACHE != 'true' && startsWith(matrix.os, 'ubuntu-')
env:
packages: >-
build-essential
cmake
curl
clang
librocksdb-dev
protobuf-compiler
llvm
python3-pip
run: |
sudo apt update -yq
sudo apt install -yq $packages
pip3 install ziglang
- name: Install MacOS tools
if: env.CACHE != 'true' && startsWith(matrix.os, 'macos-')
run: |
brew install zig protobuf openssl@3
- name: Install common tools
if: env.CACHE != 'true'
run: |
[[ -f ~/.cargo/bin/cargo-zigbuild ]] || cargo install cargo-zigbuild
- name: Build Binary ${{ matrix.dir }}/target/${{ matrix.target }}/release/${{ matrix.bin }}
working-directory: ${{ matrix.dir }}
if: env.CACHE != 'true'
env:
CARGO_INCREMENTAL: 0 # important for cache size too
CARGO_NET_RETRY: 10
RUST_BACKTRACE: full
RUSTUP_MAX_RETRIES: 10
run: |
cargo zigbuild -r --target ${{ matrix.target }}
ls -lA target/${{ matrix.target }}/release
mkdir -p ${{ env.CACHE_RESULT_DIR }}
cp target/${{ matrix.target }}/release/${{ matrix.bin }} ${{ env.CACHE_RESULT_BIN }}
ls -lA ${{ env.CACHE_RESULT_DIR }}
- name: Artifact ${{ matrix.result }}
uses: actions/upload-artifact@v3
with:
path: ${{ env.CACHE_RESULT_BIN }}
name: ${{ matrix.result }}--${{ matrix.bin }}
if-no-files-found: error
retention-days: 3
outputs:
version: ${{ steps.version.outputs.VERSION }}
release:
needs:
- build
runs-on: ubuntu-latest
strategy:
matrix:
result:
- git-remote-gosh-darwin-arm64
- git-remote-gosh-darwin-amd64
- git-remote-gosh-linux-arm64
- git-remote-gosh-linux-amd64
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Display structure of downloaded files
run: ls -R
## IMPORTANT! only works with non-windows binaries
- name: Gather all binaries "${{ matrix.result }}"
run: |
mkdir -p ${{ matrix.result }}
cp ${{ matrix.result }}--*/* ${{ matrix.result }}
ls -lA ${{ matrix.result }}
- name: Make archive
run: |
chmod +x ${{ matrix.result }}/*
printf "%s\n" ${{ matrix.result }}/git-remote-gosh_* | sort -rV | tee '${{ matrix.result }}/dispatcher.ini'
tar -czvf ${{ matrix.result }}.tar.gz -C ${{ matrix.result }} .
- name: Upload Draft
uses: softprops/action-gh-release@v1
if: env.release != 'true'
with:
draft: true
tag_name: rc-${{ needs.build.outputs.version || 'no-version' }}-${{ github.ref_name }}-${{ github.run_number }}
files: |
${{ matrix.result }}.tar.gz
body: ""
- name: Upload Prerelease
uses: softprops/action-gh-release@v1
if: env.release == 'true'
with:
prerelease: true
tag_name: rc-${{ github.ref_name }}-build-${{ github.run_number }}
files: |
${{ matrix.result }}.tar.gz
name: "Version: ${{ github.ref_name }}"
body: ""