-
Notifications
You must be signed in to change notification settings - Fork 48
189 lines (160 loc) · 5.88 KB
/
release.yml
File metadata and controls
189 lines (160 loc) · 5.88 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.archive_name }}.${{ matrix.archive_ext }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64 — native
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive_name: starforge-linux-x86_64
archive_ext: tar.gz
binary_name: starforge
# macOS ARM64 — native on macos-latest (M1 runner)
- os: macos-latest
target: aarch64-apple-darwin
archive_name: starforge-macos-aarch64
archive_ext: tar.gz
binary_name: starforge
# Windows x86_64 — native
- os: windows-latest
target: x86_64-pc-windows-msvc
archive_name: starforge-windows-x86_64
archive_ext: zip
binary_name: starforge.exe
# Linux ARM64 — cross-compiled using `cross`
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive_name: starforge-linux-aarch64
archive_ext: tar.gz
binary_name: starforge
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# Only runs for the aarch64-unknown-linux-gnu matrix entry
- name: Install aarch64 Linux cross-linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get install -y gcc-aarch64-linux-gnu
# Tells cargo which linker to use when targeting aarch64 Linux
- name: Configure cargo linker for aarch64 Linux
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
mkdir -p ~/.cargo
cat >> ~/.cargo/config.toml << 'EOF'
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}
# Linux and macOS produce .tar.gz
- name: Package binary (Linux / macOS)
if: runner.os != 'Windows'
run: |
mkdir -p dist
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} dist/starforge
else
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} dist/starforge
fi
tar -czf "dist/${{ matrix.archive_name }}.tar.gz" -C dist starforge
rm dist/starforge
# Windows produces .zip
- name: Package binary (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} dist/
cd dist
7z a "${{ matrix.archive_name }}.zip" "${{ matrix.binary_name }}"
rm "${{ matrix.binary_name }}"
# Generate checksums for all archives
- name: Generate checksums
shell: bash
run: |
cd dist
if [ "${{ runner.os }}" = "Windows" ]; then
certutil -hashfile "${{ matrix.archive_name }}.zip" SHA256 | grep -v "SHA256 hash" | grep -v "^$" > checksums.txt
else
sha256sum "${{ matrix.archive_name }}.tar.gz" >> checksums.txt
fi
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive_name }}
path: |
dist/${{ matrix.archive_name }}.*
dist/checksums.txt
release:
name: Publish GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Prepare release files
run: |
mkdir -p release-files
find release-artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec cp {} release-files/ \;
find release-artifacts -type f -name "checksums.txt" -exec cat {} >> release-files/SHA256SUMS.txt \;
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
release-files/*
homebrew:
name: Update Homebrew Formula
needs: release
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download Linux binary
uses: actions/download-artifact@v4
with:
name: starforge-linux-x86_64
path: homebrew-build
- name: Generate Homebrew formula
run: |
VERSION="${{ steps.version.outputs.version }}"
TARBALL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/starforge-linux-x86_64.tar.gz"
SHA256=$(cd homebrew-build && sha256sum starforge-linux-x86_64.tar.gz | cut -d' ' -f1)
cat > homebrew-formula.rb << EOF
class Starforge < Formula
desc "Deploy Soroban smart contracts with enhanced CLI"
homepage "https://github.com/${{ github.repository }}"
url "${TARBALL}"
sha256 "${SHA256}"
version "${VERSION}"
def install
bin.install "starforge"
end
test do
assert_match version.to_s, shell_output("#{bin}/starforge --version")
end
end
EOF
cat homebrew-formula.rb
- name: Create PR to homebrew-core (optional)
run: |
echo "Homebrew formula generated. Manual PR creation or automation can be set up."