-
Notifications
You must be signed in to change notification settings - Fork 2
190 lines (162 loc) · 4.96 KB
/
ci.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
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- v*
jobs:
build-linux:
strategy:
matrix:
platform:
- name: x86_64
target: amd64
runs-on: ubuntu-latest
- name: aarch64
target: arm64
runs-on: [self-hosted, linux, ARM64]
runs-on: ${{ matrix.platform.runs-on }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# - name: Cache Docker layers
# uses: actions/cache@v2
# with:
# path: /tmp/.buildx-cache
# key:
# "${{ runner.os }}-buildx-${{ matrix.platform.name }}-${{ github.sha
# }}"
# restore-keys: |
# ${{ runner.os }}-buildx-${{ matrix.platform.name }}
- name: Login to GitHub Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build in Docker ${{ matrix.platform.name }}
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/${{ matrix.platform.target }}
push: false
load: true
# TODO: set :latest and versioned tag, on new version
# should I even bother pushing?
# ovyerus/bandsnatch:nightly
tags: |
ghcr.io/ovyerus/bandsnatch:nightly
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache
- name: Extract binaries
run: |
id=$(docker create --platform=linux/${{ matrix.platform.target }} ghcr.io/ovyerus/bandsnatch:nightly)
docker cp $id:/bs/bandsnatch - | tar xf -
docker rm -v $id
- name: Upload ${{ matrix.platform.name }}
uses: actions/upload-artifact@v2
with:
name: bandsnatch-linux-${{ matrix.platform.name }}
path: ./bandsnatch
build-macos:
runs-on: macos-11
strategy:
matrix:
target:
- x86_64
- aarch64
steps:
- uses: actions/checkout@v2
- name: Install target
uses: actions-rs/toolchain@v1
with:
toolchain: stable-apple-darwin
target: ${{ matrix.target }}-apple-darwin
override: true
profile: minimal
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}-apple-darwin
- uses: actions/upload-artifact@v2
with:
name: bandsnatch-macos-${{ matrix.target }}
path: "target/${{ matrix.target }}-apple-darwin/release/bandsnatch"
build-windows:
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- name: Install target
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
override: true
profile: minimal
- uses: Swatinem/rust-cache@v2
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target x86_64-pc-windows-msvc
- uses: actions/upload-artifact@v2
with:
name: "bandsnatch-windows-x86_64"
path: "target/x86_64-pc-windows-msvc/release/bandsnatch.exe"
# TODO: clippy lints & rustfmt
create-release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- build-linux
- build-macos
- build-windows
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Rename files
run: |
mkdir out && cd out
declare -a arr=(
"windows-x86_64"
"macos-x86_64"
"macos-aarch64"
"linux-x86_64"
"linux-aarch64"
)
for target in "${arr[@]}"
do
if [[ "$target" == *windows* ]]; then
src="../bandsnatch-$target/bandsnatch.exe"
filename="bandsnatch-$target.exe"
else
src="../bandsnatch-$target/bandsnatch"
filename="bandsnatch-$target"
fi
cp $src $filename
sha256sum "$filename" >> "checksums.txt"
done
- name: Create draft release
uses: softprops/action-gh-release@v1
with:
body: Update the description for the release!
draft: true
files: ./out/*
- name: Update Homebrew tap
uses: mislav/bump-homebrew-formula-action@v2
with:
formula-name: bandsnatch
homebrew-tap: Ovyerus/homebrew-tap
env:
COMMITTER_TOKEN: ${{ secrets.TAP_COMMITTER_TOKEN }}