-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (126 loc) · 3.97 KB
/
release.yml
File metadata and controls
144 lines (126 loc) · 3.97 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
name: release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
validate-tag-version:
name: validate-tag-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate tag matches Cargo version
shell: bash
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
cargo_version="$(
awk '
/^\[workspace\.package\]/ { in_section=1; next }
/^\[/ { if (in_section) exit }
in_section && $1 == "version" {
gsub(/"/, "", $3)
print $3
exit
}
' Cargo.toml
)"
if [[ -z "${cargo_version}" ]]; then
echo "Could not resolve workspace.package.version from Cargo.toml" >&2
exit 1
fi
expected_tag="v${cargo_version}"
if [[ "${tag}" != "${expected_tag}" ]]; then
echo "Tag/version mismatch:" >&2
echo " tag: ${tag}" >&2
echo " Cargo.toml workspace version: ${cargo_version}" >&2
echo " expected tag: ${expected_tag}" >&2
exit 1
fi
echo "Tag/version check passed: ${tag}"
build:
name: build-${{ matrix.archive_os }}-${{ matrix.archive_arch }}
needs: [validate-tag-version]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
archive_os: linux
archive_arch: x86_64
- runner: macos-15-intel
archive_os: darwin
archive_arch: x86_64
- runner: macos-14
archive_os: darwin
archive_arch: aarch64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build binaries
run: cargo build --release -p clawform
- name: Package artifacts
shell: bash
run: |
set -euo pipefail
asset="clawform_${{ matrix.archive_os }}_${{ matrix.archive_arch }}.tar.gz"
mkdir -p dist
cp target/release/clawform dist/clawform
cp target/release/cf dist/cf
chmod +x dist/clawform dist/cf
tar -C dist -czf "$asset" clawform cf
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$asset" > "${asset}.sha256"
else
shasum -a 256 "$asset" > "${asset}.sha256"
fi
- name: Upload packaged artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.archive_os }}-${{ matrix.archive_arch }}
path: |
clawform_${{ matrix.archive_os }}_${{ matrix.archive_arch }}.tar.gz
clawform_${{ matrix.archive_os }}_${{ matrix.archive_arch }}.tar.gz.sha256
if-no-files-found: error
publish:
name: publish-release
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Prepare release files
shell: bash
run: |
set -euo pipefail
find dist -type f -name "*.tar.gz" -exec cp {} dist/ \;
find dist -type f -name "*.tar.gz.sha256" -print0 \
| sort -z \
| xargs -0 cat > dist/SHA256SUMS
ls -lah dist
- name: Detect release type
id: meta
shell: bash
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
if [[ "${tag}" == *-* ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ steps.meta.outputs.is_prerelease }}
files: |
dist/*.tar.gz
dist/SHA256SUMS