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
name: release
on:
push:
tags:
- "v*"
permissions:
attestations: write
contents: write
id-token: write
defaults:
run:
shell: bash
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Dwarnings
jobs:
test:
uses: ./.github/workflows/ci.yml
with:
release: true
draft:
runs-on: ubuntu-latest
needs: test
steps:
# Check out with full history to generate release notes.
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up toolchain
run: rustup install
- name: Draft release
run: gh release create '${{ github.ref_name }}' --draft --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-14 # arm64
- ubuntu-22.04
- ubuntu-22.04-arm
- windows-2022
- windows-11-arm
include:
- os: windows-2022
extension: '.exe'
- os: windows-11-arm
extension: '.exe'
needs: draft
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Set up toolchain
run: rustup install
- name: Install openssl (Windows)
if: runner.os == 'Windows'
run: |
echo "OPENSSL_DIR=C:\Program Files\OpenSSL" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=C:\Program Files\OpenSSL\lib\VC\${{ runner.arch }}\MT" >> $GITHUB_ENV
- name: Build
id: build
run: |
cargo build --release --all-features --workspace
echo "dir=target/release/" | tee -a "$GITHUB_OUTPUT"
echo "name=akv${{ matrix.extension }}" | tee -a "$GITHUB_OUTPUT"
echo "target=target/release/akv${{ matrix.extension }}" | tee -a "$GITHUB_OUTPUT"
- name: Attest executable
uses: actions/attest-build-provenance@v2
with:
subject-path: ${{ steps.build.outputs.target }}
- name: Package
id: package
shell: pwsh
run: |
$name = 'akv-${{ runner.os }}-${{ runner.arch }}'.ToLowerInvariant() -replace 'x64', 'amd64'
if ('${{ runner.os }}' -eq 'Windows') {
$name = "$name.zip"
$target = "target/release/$name"
Compress-Archive -Path ${{ steps.build.outputs.target }} -DestinationPath $target
} else {
$name = "$name.tar.gz"
$target = "target/release/$name"
tar czf "$target" -C ${{ steps.build.outputs.dir }} ${{ steps.build.outputs.name }}
}
"name=$name" >> $env:GITHUB_OUTPUT
"target=$target" >> $env:GITHUB_OUTPUT
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.name }}
path: ${{ steps.package.outputs.target }}
- name: Publish
run: gh release upload '${{ github.ref_name }}' '${{ steps.package.outputs.target }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
attest:
runs-on: ubuntu-latest
needs: package
steps:
- name: Download
uses: actions/download-artifact@v4
- name: Attest
uses: actions/attest-build-provenance@v2
with:
subject-path: ${{ github.workspace }}/*
# Publish separately to crates.io to allow retries e.g., expired token.
publish:
runs-on: ubuntu-latest
needs: package
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up toolchain
run: rustup install
- name: Authenticate with crates.io
id: auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
release:
runs-on: ubuntu-latest
needs: attest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Release
run: gh release edit '${{ github.ref_name }}' --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
brew:
needs: release
uses: ./.github/workflows/brew.yml
with:
tag: ${{ github.ref_name }}
secrets:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}