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
name: Release
on:
push:
tags:
workflow_dispatch:
permissions:
contents: read
jobs:
release:
if: github.repository_owner == 'wagov-dtt'
name: Release (${{ matrix.target }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
archive: tar.gz
- os: macos-14
target: aarch64-apple-darwin
archive: tar.gz
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: jdx/mise-action@v4
- name: Add cross-compilation target
run: rustup target add ${{ matrix.target }}
- name: Build size-optimized release binary
env:
RUSTFLAGS: -C debuginfo=0
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Strip binary
shell: bash
run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then
strip target/${{ matrix.target }}/release/oy
else
strip --strip-all target/${{ matrix.target }}/release/oy
fi
- name: Package
shell: bash
env:
REF_NAME: ${{ github.ref_name }}
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/oy dist/oy
tar -C dist -czf "oy-${REF_NAME}-${{ matrix.target }}.tar.gz" oy
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: oy-${{ github.ref_name }}-${{ matrix.target }}
path: oy-${{ github.ref_name }}-${{ matrix.target }}.${{ matrix.archive }}
if-no-files-found: error
publish-release:
if: github.repository_owner == 'wagov-dtt'
needs: release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
merge-multiple: true
- name: Attest release assets
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
with:
subject-path: dist/*
- name: Create draft GitHub release with assets
env:
GH_TOKEN: ${{ github.token }}
REF_NAME: ${{ github.ref_name }}
REPOSITORY: ${{ github.repository }}
SHA: ${{ github.sha }}
run: |
gh release create "${REF_NAME}" dist/* \
--repo "${REPOSITORY}" \
--draft \
--target "${SHA}" \
--title "${REF_NAME}" \
--notes "Rust release ${REF_NAME}."
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
REF_NAME: ${{ github.ref_name }}
REPOSITORY: ${{ github.repository }}
run: gh release edit "${REF_NAME}" --repo "${REPOSITORY}" --draft=false
publish-crate:
if: github.repository_owner == 'wagov-dtt'
needs: release
runs-on: ubuntu-latest
environment: crates-io
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: jdx/mise-action@v4
- name: Verify crate package
run: cargo package --locked
- name: Authenticate with crates.io
id: auth
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
- name: Publish crate to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish --locked