-
Notifications
You must be signed in to change notification settings - Fork 4
171 lines (150 loc) · 4.61 KB
/
Copy pathrelease.yaml
File metadata and controls
171 lines (150 loc) · 4.61 KB
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
name: Release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
BIN_NAME: ${{ github.event.repository.name }}
REGISTRY: ghcr.io
permissions:
contents: write
packages: write
jobs:
prepare:
name: Prepare Environment
runs-on: ubuntu-latest
outputs:
is_prerelease: ${{ steps.eval.outputs.is_prerelease }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Evaluate Tags
id: eval
run: |
if [[ "${GITHUB_REF#refs/tags/}" == *-* ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: taiki-e/create-gh-release-action@v1
with:
changelog: CHANGELOG.md
draft: true
build:
name: Build ${{ matrix.target }}
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cpu: x86-64-v3
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cpu: x86-64-v3
- target: aarch64-unknown-linux-musl
os: ubuntu-24.04-arm
cpu: neoverse-n1
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
cpu: neoverse-n1
- target: x86_64-apple-darwin
os: macos-15-intel
cpu: x86-64-v3
- target: aarch64-apple-darwin
os: macos-latest
cpu: apple-m1
- target: x86_64-pc-windows-msvc
os: windows-latest
cpu: x86-64-v3
- target: aarch64-pc-windows-msvc
os: windows-11-arm
cpu: cortex-a76
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install musl-tools
if: contains(matrix.target, '-musl')
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build and Upload Binary
uses: taiki-e/upload-rust-binary-action@v1
env:
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
with:
bin: ${{ env.BIN_NAME }}
target: ${{ matrix.target }}
build-tool: cargo
locked: true
include: LICENSE,README.md
archive: $bin-$target
- name: Upload Binary for Docker
if: contains(matrix.target, 'linux-musl')
uses: actions/upload-artifact@v7
with:
name: binary-${{ matrix.target }}
path: target/${{ matrix.target }}/release/${{ env.BIN_NAME }}
retention-days: 1
publish:
name: Publish Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Publish Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release edit ${{ github.ref_name }} --draft=false
docker:
name: Docker Push
needs:
- prepare
- build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download amd64 Binary
uses: actions/download-artifact@v8
with:
name: binary-x86_64-unknown-linux-musl
path: bin/amd64
- name: Download arm64 Binary
uses: actions/download-artifact@v8
with:
name: binary-aarch64-unknown-linux-musl
path: bin/arm64
- name: Make Binaries Executable
run: chmod +x -R bin/
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log In to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=raw,value=latest,enable=${{ needs.prepare.outputs.is_prerelease != 'true' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}},enable=${{ needs.prepare.outputs.is_prerelease != 'true' }}
- name: Build and Push Image
uses: docker/build-push-action@v7
with:
context: .
file: .github/workflows/Dockerfile.release
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}