Repository navigation
130 lines (114 loc) · 3.79 KB
/
Copy pathrelease.yml
File metadata and controls
130 lines (114 loc) · 3.79 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
name: release
on:
push:
tags:
- "v*.*.*"
# Manual path for cutting a release without pushing a tag first; the
# publish step creates the tag on the commit the run was started from.
workflow_dispatch:
inputs:
tag:
description: "Tag to release, e.g. v0.1.0 (must match Cargo.toml)"
required: true
env:
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
permissions:
contents: write
id-token: write
attestations: write
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify the tag matches Cargo.toml's version
run: |
tag_version="${RELEASE_TAG#v}"
cargo_version=$(grep -m1 '^version' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
if [ "$tag_version" != "$cargo_version" ]; then
echo "Tag $RELEASE_TAG doesn't match Cargo.toml version $cargo_version" >&2
exit 1
fi
build:
needs: check-version
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive_ext: tar.gz
# Cross-compiled on Apple Silicon: the macos-13 Intel runners
# were retired.
- target: x86_64-apple-darwin
os: macos-14
archive_ext: tar.gz
- target: aarch64-apple-darwin
os: macos-14
archive_ext: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive_ext: zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }} --locked
- name: Package (unix)
if: matrix.archive_ext == 'tar.gz'
run: |
name=formwatch-${{ matrix.target }}
mkdir "$name"
cp target/${{ matrix.target }}/release/formwatch "$name"/
cp README.md LICENSE NOTICE "$name"/
tar czf "$name.tar.gz" "$name"
- name: Package (windows)
if: matrix.archive_ext == 'zip'
shell: pwsh
run: |
$name = "formwatch-${{ matrix.target }}"
New-Item -ItemType Directory -Path $name
Copy-Item "target/${{ matrix.target }}/release/formwatch.exe" $name/
Copy-Item README.md,LICENSE,NOTICE $name/
Compress-Archive -Path $name -DestinationPath "$name.zip"
- name: Upload archive
uses: actions/upload-artifact@v4
with:
name: formwatch-${{ matrix.target }}
path: formwatch-${{ matrix.target }}.${{ matrix.archive_ext }}
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all built archives
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate checksums
working-directory: dist
run: sha256sum formwatch-* > SHA256SUMS.txt && cat SHA256SUMS.txt
- name: Generate an SBOM (CycloneDX)
run: |
cargo install cargo-cyclonedx --locked --quiet
cargo cyclonedx --format json --all
cp formwatch.cdx.json dist/formwatch.cdx.json
- name: Attest build provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: "dist/formwatch-*"
- name: Publish release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
target_commitish: ${{ github.sha }}
generate_release_notes: true
files: |
dist/formwatch-*
dist/SHA256SUMS.txt
dist/formwatch.cdx.json