-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (156 loc) · 5.15 KB
/
dev-release.yaml
File metadata and controls
178 lines (156 loc) · 5.15 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
172
173
174
175
176
177
178
name: Dev Release
on:
push:
branches:
- "master"
tags-ignore:
- "**"
env:
BIN_NAME: ${{ github.event.repository.name }}
REGISTRY: ghcr.io
permissions:
contents: write
packages: write
jobs:
build-dev:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
cpu: x86-64-v3
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
install_deps: "false"
cpu: x86-64-v3
- target: aarch64-unknown-linux-musl
os: ubuntu-24.04-arm
install_deps: sudo apt-get update && sudo apt-get install -y musl-tools
cpu: neoverse-n1
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
install_deps: "false"
cpu: neoverse-n1
- target: x86_64-apple-darwin
os: macos-15-intel
install_deps: "false"
cpu: x86-64-v3
- target: aarch64-apple-darwin
os: macos-latest
install_deps: "false"
cpu: apple-m1
- target: x86_64-pc-windows-msvc
os: windows-latest
install_deps: "false"
cpu: x86-64-v3
- target: aarch64-pc-windows-msvc
os: windows-11-arm
install_deps: "false"
cpu: cortex-a76
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 }}
- name: Set Dev Version
shell: bash
run: |
BASE_VERSION=$(grep -m1 'version = "' Cargo.toml | cut -d '"' -f 2)
SHORT_SHA=$(git rev-parse --short HEAD)
NEW_VERSION="${BASE_VERSION}-dev.${SHORT_SHA}"
sed -i.bak "s/^version = .*/version = \"$NEW_VERSION\"/" Cargo.toml
- name: Build Binary
env:
RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}"
run: |
rm -f .cargo/config.toml # RUSTFLAGS="-C target_cpu=native" and apple-m1 CPUs cause brittle behavior
cargo build --release --target ${{ matrix.target }}
- name: Package Binary
shell: bash
run: |
mkdir dist
cp LICENSE 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
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
fi
- name: Upload Artifact
uses: actions/upload-artifact@v6
with:
name: binary-${{ matrix.target }}
path: ${{ env.BIN_NAME }}-${{ matrix.target }}*
retention-days: 1
release-dev:
name: Update Dev Release
needs: build-dev
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v6
with:
path: artifacts
merge-multiple: true
- name: Update Pre-Release
uses: softprops/action-gh-release@v2
with:
tag_name: dev
name: Development Build
body: "Latest development build from master. Commit: ${{ github.sha }}"
prerelease: true
files: artifacts/*
make_latest: false
docker-dev:
name: Push Dev Docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set Dev Version
shell: bash
run: |
BASE_VERSION=$(grep -m1 'version = "' Cargo.toml | cut -d '"' -f 2)
SHORT_SHA=$(git rev-parse --short HEAD)
NEW_VERSION="${BASE_VERSION}-dev.${SHORT_SHA}"
sed -i.bak "s/^version = .*/version = \"$NEW_VERSION\"/" Cargo.toml
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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: Build and push
uses: docker/build-push-action@v6
with:
context: .
build-args: |
LOCK_FLAG=
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ github.repository }}:dev
cache-from: type=gha
cache-to: type=gha,mode=max