-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (132 loc) · 4.61 KB
/
Copy pathrelease-cli.yml
File metadata and controls
155 lines (132 loc) · 4.61 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
name: Release CLI
on:
push:
tags:
- 'cli-v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g. cli-v0.1.0)'
required: true
# Only runs in the public repo (gaffer-sh/gaffer). Synced from monorepo via scripts/sync-cli-repo.sh.
concurrency:
group: release-cli-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
if: github.repository == 'gaffer-sh/gaffer'
strategy:
matrix:
include:
- target: aarch64-apple-darwin
runner: macos-14
use_zigbuild: false
- target: x86_64-apple-darwin
runner: macos-15-intel
use_zigbuild: false
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
use_zigbuild: true
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
use_zigbuild: true
- target: x86_64-pc-windows-gnu
runner: ubuntu-latest
use_zigbuild: true
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cargo-zigbuild
if: matrix.use_zigbuild
run: pip3 install ziglang && cargo install cargo-zigbuild
- name: Build (native)
if: "!matrix.use_zigbuild"
run: cargo build --release --target ${{ matrix.target }} -p gaffer
- name: Build (zigbuild)
if: matrix.use_zigbuild
run: cargo zigbuild --release --target ${{ matrix.target }} -p gaffer
- name: Package
run: |
cd target/${{ matrix.target }}/release
if [[ "${{ matrix.target }}" == *windows* ]]; then
tar czf ../../../gaffer-${{ matrix.target }}.tar.gz gaffer.exe
else
tar czf ../../../gaffer-${{ matrix.target }}.tar.gz gaffer
fi
cd ../../..
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: gaffer-${{ matrix.target }}
path: gaffer-${{ matrix.target }}.tar.gz
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Determine tag
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
if ! echo "$TAG" | grep -qE '^cli-v[0-9]+\.[0-9]+\.[0-9]+'; then
echo "Error: Tag must match 'cli-v*' format (e.g., cli-v0.1.0). Got: $TAG"
exit 1
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
else
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
fi
- name: Extract version from tag
id: version
run: |
TAG="${{ steps.tag.outputs.tag }}"
VERSION="${TAG#cli-v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Verify version matches Cargo.toml
run: |
CARGO_VERSION=$(grep '^version' packages/cli/Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
if [ "$CARGO_VERSION" != "${{ steps.version.outputs.version }}" ]; then
echo "Error: Tag version (${{ steps.version.outputs.version }}) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
- name: Download all artifacts
uses: actions/download-artifact@v6
with:
path: artifacts
- name: Verify all artifacts present
run: |
for target in aarch64-apple-darwin x86_64-apple-darwin x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-pc-windows-gnu; do
if [ ! -f "artifacts/gaffer-$target/gaffer-$target.tar.gz" ]; then
echo "Error: Missing artifact for $target"
exit 1
fi
done
echo "All 5 platform artifacts present."
- name: Collect tarballs and generate checksums
run: |
mkdir -p release
cp artifacts/gaffer-*/gaffer-*.tar.gz release/
cd release
sha256sum gaffer-*.tar.gz > checksums.txt
cat checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: Gaffer CLI ${{ steps.version.outputs.version }}
files: |
release/gaffer-*.tar.gz
release/checksums.txt
generate_release_notes: true