-
-
Notifications
You must be signed in to change notification settings - Fork 1
183 lines (155 loc) · 4.55 KB
/
release.yml
File metadata and controls
183 lines (155 loc) · 4.55 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
179
180
181
182
183
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
packages: write
jobs:
docker:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Docker metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest
type=ref,event=tag
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
file: Dockerfile.multi
push: true
tags: ${{ steps.metadata.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: ow-linux-x86_64
use_cross: false
# Linux aarch64 (ARM64)
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: ow-linux-aarch64
use_cross: true
# macOS Intel
- target: x86_64-apple-darwin
os: macos-latest
name: ow-macos-x86_64
use_cross: false
# macOS Apple Silicon
- target: aarch64-apple-darwin
os: macos-latest
name: ow-macos-aarch64
use_cross: false
# Windows
- target: x86_64-pc-windows-msvc
os: windows-latest
name: ow-windows-x86_64.exe
use_cross: false
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.use_cross == true
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Build (cross)
if: matrix.use_cross == true
run: cross build --release --target ${{ matrix.target }}
- name: Build (cargo)
if: matrix.use_cross == false
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare binary (Unix)
if: runner.os != 'Windows'
run: |
cp target/${{ matrix.target }}/release/ow ow
chmod +x ow
tar czf ${{ matrix.name }}.tar.gz ow
- name: Prepare binary (Windows)
if: runner.os == 'Windows'
run: |
copy target\${{ matrix.target }}\release\ow.exe ow.exe
7z a ${{ matrix.name }}.zip ow.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: |
${{ matrix.name }}.tar.gz
${{ matrix.name }}.zip
if-no-files-found: ignore
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure
run: ls -R artifacts
- name: Create checksums
run: |
cd artifacts
for dir in */; do
cd "$dir"
for file in *; do
if [ -f "$file" ]; then
sha256sum "$file" >> ../checksums.txt
fi
done
cd ..
done
cat checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: false
generate_release_notes: true
files: |
artifacts/*/*.tar.gz
artifacts/*/*.zip
artifacts/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crates:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}