-
-
Notifications
You must be signed in to change notification settings - Fork 8
279 lines (262 loc) · 7.88 KB
/
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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
name: Release
on:
workflow_dispatch:
inputs:
test_build:
description: 'Create test builds'
type: boolean
required: true
default: false
pull_request_target:
types:
- closed
branches:
- main
paths-ignore:
- '**.md'
- '**.png'
# push:
# branches:
# - main
# paths-ignore:
# - '**.md'
env:
REGISTRY_IMAGE: ghcr.io/lostb1t/replex
permissions:
contents: write
pull-requests: write
concurrency:
group: release
# If this is enabled it will cancel current running and start latest
cancel-in-progress: true
jobs:
get-next-version:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
uses: semantic-release-action/next-release-version/.github/workflows/next-release-version.yml@v4
# test:
# name: Test
# runs-on: ubuntu-20.04
# continue-on-error: false
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Install Rust
# uses: dtolnay/rust-toolchain@stable
# - name: Run Tests
# run: make run-tests
# shell: bash
build:
if: needs.get-next-version.outputs.new-release-published == 'true' || inputs.test_build
name: Build - ${{ matrix.platform.release_for }}
strategy:
matrix:
platform:
- release_for: x86_64 Linux
os: ubuntu-22.04
docker: linux/amd64
target: x86_64-unknown-linux-gnu
bin: replex
name: x86_64-unknown-linux-gnu.tar.gz
command: build
- release_for: ARM64 Linux
os: ubuntu-22.04
docker: linux/arm64
target: aarch64-unknown-linux-gnu
bin: replex
name: aarch64-unknown-linux-gnu.tar.gz
command: build
# - release_for: x86_64 macOS
# os: macOS-latest
# docker: darwin/amd64
# target: x86_64-apple-darwin
# bin: replex
# name: x86_64-apple-darwin.tar.gz
# command: build
# - release_for: ARM64 macOS
# os: macOS-latest
# target: aarch64-apple-darwin
# bin: replex
# name: aarch64-apple-darwin.tar.gz
# command: build
#- release_for: x86_64 Windows
# os: windows-latest
# target: x86_64-pc-windows-msvc
# bin: replex.exe
# name: precious-Windows-x86_64.zip
# command: build
runs-on: ${{ matrix.platform.os }}
needs:
- get-next-version
env:
HUSKY: 0
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.platform.target }}
- name: Install semantic-release-cargo
if: ${{ !inputs.test_build }}
uses: taiki-e/install-action@v2
with:
tool: semantic-release-cargo@2
- name: Prepare semantic-release for Rust
if: ${{ !inputs.test_build }}
run: semantic-release-cargo prepare ${{ needs.get-next-version.outputs.new-release-version }}
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
# env:
# CARGO_TARGET_DIR: ./ci-target
with:
command: ${{ matrix.platform.command }}
target: ${{ matrix.platform.target }}
args: "--locked --release"
- name: Move bin
shell: bash
run: |
mkdir -p bin/${{ matrix.platform.target }}
mv target/${{ matrix.platform.target }}/release/replex bin/${{ matrix.platform.target }}/${{ matrix.platform.bin }}
-
name: Upload artifacts
uses: actions/upload-artifact@v3
with:
# name: ${{ matrix.platform.target }}
name: bin
path: bin/*
if-no-files-found: error
retention-days: 1
# -
# name: Build image and push by digest
# id: build
# uses: docker/build-push-action@v4
# with:
# context: .
# file: docker/Dockerfile.test.github
# platforms: ${{ matrix.platform.docker }}
# labels: ${{ steps.meta.outputs.labels }}
# # tags: |
# # user/app:latest
# # user/app:1.0.0
# # ghcr.io/user/app:latest
# # ghcr.io/user/app:1.0.0
# outputs: type=image,name=${{ env.REGISTRY_IMAGE }}push-by-digest=true,name-canonical=true,push=true
# -
# name: Export digest
# run: |
# mkdir -p /tmp/digests
# digest="${{ steps.build.outputs.digest }}"
# touch "/tmp/digests/${digest#sha256:}"
# -
# name: Upload digest
# uses: actions/upload-artifact@v3
# with:
# name: digests
# path: /tmp/digests/*
# if-no-files-found: error
# retention-days: 1
# - name: Invoke semantic-release
# if: ${{ !inputs.test_build }}
# env:
# GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
# run: npx semantic-release
build-docker-images:
runs-on: ubuntu-latest
needs:
- build
- get-next-version
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Download bin
uses: actions/download-artifact@v3
with:
name: bin
path: bin/
- name: check bin path
run: ls -al bin
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=${{ needs.get-next-version.outputs.new-release-version }},enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.PERSONAL_TOKEN }}
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: setup qemu
uses: docker/setup-qemu-action@v2
- uses: docker/build-push-action@v4
with:
push: true
# push: ${{ github.event_name != 'pull_request' }}
context: .
platforms: linux/amd64,linux/arm64
# file: ./.github/workflows/Dockerfile.ci
file: docker/Dockerfile.github
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha,mode=max
cache-from: type=gha
release:
if: ${{ !inputs.test_build }}
runs-on: ubuntu-latest
needs:
- build
env:
HUSKY: 0
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Download bin
uses: actions/download-artifact@v3
with:
name: bin
path: bin/
- name: Package as archive
shell: bash
run: |
mkdir -p assets
cd bin
for dir in */; do
(
cd $dir
name=${dir%/}
if [[ "$name" == *"windows"* ]]; then
7z a ../../assets/$name.7z ./
else
chmod +x ./replex
tar czvf ../../assets/$name.tar.gz ./
fi
)
done
cd -
- name: Invoke semantic-release
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
run: npx semantic-release@22