-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (144 loc) · 4.7 KB
/
stable-release.yaml
File metadata and controls
163 lines (144 loc) · 4.7 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
name: Stable Release
on:
push:
tags:
- "v*"
env:
BIN_NAME: ${{ github.event.repository.name }}
REGISTRY: ghcr.io
permissions:
contents: write
packages: write
jobs:
build-stable:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cpu: x86-64-v3
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cpu: x86-64-v3
install_deps: "false"
- target: aarch64-unknown-linux-musl
os: ubuntu-24.04-arm
cpu: neoverse-n1
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
cpu: neoverse-n1
install_deps: "false"
- target: x86_64-apple-darwin
os: macos-15-intel
cpu: x86-64-v3
install_deps: "false"
- target: aarch64-apple-darwin
os: macos-latest
cpu: apple-m1
install_deps: "false"
- target: x86_64-pc-windows-msvc
os: windows-latest
cpu: x86-64-v3
install_deps: "false"
- target: aarch64-pc-windows-msvc
os: windows-11-arm
cpu: cortex-a76
install_deps: "false"
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install System Dependencies
if: matrix.install_deps != 'false'
run: ${{ matrix.install_deps }}
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
# RUSTFLAGS="-C target_cpu=native" and apple-m1 CPUs cause brittle behavior
- name: Delete Cargo Config
shell: bash
run: rm -f .cargo/config.toml
- name: Build Binary
env:
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
run: cargo build --release --target ${{ matrix.target }}
- name: Package Binary
shell: bash
run: |
mkdir dist
cp LICENSE README.md dist/
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" dist/
cd dist
7z a "../${{ env.BIN_NAME }}-${{ matrix.target }}.zip" "${{ env.BIN_NAME }}.exe" LICENSE README.md
else
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" dist/
cd dist
tar -czf "../${{ env.BIN_NAME }}-${{ matrix.target }}.tar.gz" "${{ env.BIN_NAME }}" LICENSE README.md
fi
- name: Upload Artifact
uses: actions/upload-artifact@v6
with:
name: binary-${{ matrix.target }}
path: ${{ env.BIN_NAME }}-${{ matrix.target }}*
retention-days: 1
release-stable:
name: Create Official Release
needs: build-stable
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v6
with:
path: artifacts
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/*
make_latest: true
docker-stable:
name: Push Stable Docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{version}}-,format=short
type=sha,prefix={{version}}-,format=long
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max