-
Notifications
You must be signed in to change notification settings - Fork 3
240 lines (211 loc) · 8.46 KB
/
Copy pathbump-nono.yml
File metadata and controls
240 lines (211 loc) · 8.46 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: Bump nono dependency
on:
repository_dispatch:
types: [nono-release]
workflow_dispatch:
inputs:
nono_version:
description: 'nono version to bump to (e.g., v0.33.0)'
required: true
type: string
permissions:
contents: read
concurrency:
group: bump-nono-${{ github.event.client_payload.nono_version || github.event.inputs.nono_version }}
cancel-in-progress: false
jobs:
rebuild-libs:
name: Rebuild nono-ffi for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
env:
NONO_VERSION: ${{ github.event.client_payload.nono_version || github.event.inputs.nono_version }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
platform: linux_amd64
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
platform: linux_arm64
cross: true
- target: x86_64-apple-darwin
os: macos-latest
platform: darwin_amd64
- target: aarch64-apple-darwin
os: macos-14
platform: darwin_arm64
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Validate nono version
run: |
if ! echo "$NONO_VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Invalid nono version: $NONO_VERSION" >&2
exit 1
fi
- name: Clone nono at release tag
run: |
git clone --depth 1 --branch "$NONO_VERSION" \
https://github.com/nolabs-ai/nono.git /tmp/nono
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
with:
targets: ${{ matrix.target }}
- name: Cache Cargo
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
~/.cargo/bin/cross
key: cargo-${{ runner.os }}-${{ matrix.target }}-${{ env.NONO_VERSION }}
restore-keys: |
cargo-${{ runner.os }}-${{ matrix.target }}-
cargo-${{ runner.os }}-
- name: Install system dependencies (Linux)
if: runner.os == 'Linux' && !matrix.cross
run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev pkg-config
- name: Install cross (Linux ARM64)
if: matrix.cross
run: command -v cross || cargo install cross
- name: Build libnono_ffi.a
run: |
cd /tmp/nono
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }} -p nono-ffi
else
cargo build --release --target ${{ matrix.target }} -p nono-ffi
fi
- name: Stage library artifact
env:
PLATFORM: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
run: |
mkdir -p "artifact/$PLATFORM"
cp "/tmp/nono/target/$TARGET/release/libnono_ffi.a" "artifact/$PLATFORM/libnono_ffi.a"
cp /tmp/nono/bindings/c/include/nono.h "artifact/$PLATFORM/nono.h"
- name: Upload library artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: libnono-${{ matrix.platform }}
path: artifact/${{ matrix.platform }}/*
create-pr:
name: Create bump PR
needs: rebuild-libs
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
NONO_VERSION: ${{ github.event.client_payload.nono_version || github.event.inputs.nono_version }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: '1.24'
cache: true
- name: Strip v prefix
id: version
run: |
if ! echo "$NONO_VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Invalid nono version: $NONO_VERSION" >&2
exit 1
fi
VERSION="${NONO_VERSION#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "branch=bump-nono-${VERSION}" >> "$GITHUB_OUTPUT"
- name: Check if PR already exists
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXISTING=$(gh pr list --search "bump nono to ${{ steps.version.outputs.version }}" --state open --json number --jq '.[0].number')
if [ -n "$EXISTING" ]; then
echo "PR #$EXISTING already exists, skipping"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Download all library artifacts
if: steps.check.outputs.skip != 'true'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: artifacts
- name: Validate library artifacts
if: steps.check.outputs.skip != 'true'
run: |
for platform in darwin_amd64 darwin_arm64 linux_amd64 linux_arm64; do
test -s "artifacts/libnono-${platform}/libnono_ffi.a"
test -s "artifacts/libnono-${platform}/nono.h"
done
for platform in darwin_amd64 linux_amd64 linux_arm64; do
cmp -s "artifacts/libnono-darwin_arm64/nono.h" \
"artifacts/libnono-${platform}/nono.h"
done
- name: Update bundled libraries
if: steps.check.outputs.skip != 'true'
run: |
git init /tmp/nono-tag
git -C /tmp/nono-tag remote add origin https://github.com/nolabs-ai/nono.git
git -C /tmp/nono-tag fetch --depth=1 origin \
"refs/tags/${NONO_VERSION}:refs/tags/${NONO_VERSION}"
NONO_SHA=$(git -C /tmp/nono-tag rev-list -n 1 "$NONO_VERSION")
if ! echo "$NONO_SHA" | grep -Eq '^[0-9a-f]{40}$'; then
echo "Error: Could not resolve SHA for tag ${NONO_VERSION}"
exit 1
fi
for entry in \
"darwin_amd64 x86_64-apple-darwin" \
"darwin_arm64 aarch64-apple-darwin" \
"linux_amd64 x86_64-unknown-linux-gnu" \
"linux_arm64 aarch64-unknown-linux-gnu"; do
set -- $entry
platform="$1"
target="$2"
cp "artifacts/libnono-${platform}/libnono_ffi.a" "internal/clib/${platform}/libnono_ffi.a"
{
echo "# nono upstream commit used to build libnono_ffi.a for $target"
echo "# Update this file whenever the bundled library is rebuilt."
echo "$NONO_SHA"
} > "internal/clib/${platform}/VERSION"
done
# Update shared header
cp artifacts/libnono-darwin_arm64/nono.h internal/clib/nono.h
go run internal/clib/manifest.go -write
- name: Validate updated Go package
if: steps.check.outputs.skip != 'true'
env:
NONO_REQUIRE_APPLY: "1"
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-dev pkg-config
go test -v -count=1 ./...
- name: Create Pull Request
if: steps.check.outputs.skip != 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.version.outputs.branch }}
commit-message: "chore(deps): bump nono to ${{ steps.version.outputs.version }}"
title: "chore(deps): bump nono to ${{ steps.version.outputs.version }}"
body: |
Automated PR to rebuild bundled `libnono_ffi.a` static libraries from nono `${{ env.NONO_VERSION }}`.
Triggered by [nono ${{ env.NONO_VERSION }}](https://github.com/nolabs-ai/nono/releases/tag/${{ env.NONO_VERSION }}).
### Updated libraries
- `internal/clib/darwin_amd64/libnono_ffi.a`
- `internal/clib/darwin_arm64/libnono_ffi.a`
- `internal/clib/linux_amd64/libnono_ffi.a`
- `internal/clib/linux_arm64/libnono_ffi.a`
- `internal/clib/nono.h`
## Checklist
- [ ] CI passes
- [ ] `go test ./...` passes with new libraries
labels: dependencies,automated