-
Notifications
You must be signed in to change notification settings - Fork 81
222 lines (195 loc) · 7.05 KB
/
Copy pathrelease-go-binding.yml
File metadata and controls
222 lines (195 loc) · 7.05 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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Release Go Binding
on:
push:
tags:
# Trigger this workflow when tag follows the versioning format: v<major>.<minor>.<patch> OR v<major>.<minor>.<patch>-rc<release_candidate>
# Example valid tags: v0.4.0, v0.4.0-rc1
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
workflow_dispatch:
inputs:
version:
description: Release version, for example v0.1.0 or v0.1.0-rc1
required: true
type: string
source_ref:
description: Rust release baseline ref, for example main, v0.1.0-rc1, or a commit SHA
required: true
type: string
permissions:
contents: write
jobs:
validate:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
source_ref: ${{ steps.meta.outputs.source_ref }}
tag: ${{ steps.meta.outputs.tag }}
source_sha: ${{ steps.meta.outputs.source_sha }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ inputs.source_ref || github.sha }}
- name: Validate release version and tag
id: meta
shell: bash
run: |
event_name='${{ github.event_name }}'
version=''
source_ref=''
if [[ "$event_name" == "workflow_dispatch" ]]; then
version='${{ inputs.version }}'
source_ref='${{ inputs.source_ref }}'
else
tag_name='${{ github.ref_name }}'
source_ref='${{ github.sha }}'
version="$tag_name"
fi
if [[ ! "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]]; then
echo "invalid version: $version; expected vX.Y.Z or vX.Y.Z-rc.N" >&2
exit 1
fi
if [[ -z "$source_ref" ]]; then
echo "source_ref must not be empty" >&2
exit 1
fi
git rev-parse --verify "$source_ref^{commit}" >/dev/null 2>&1 || {
echo "source_ref does not resolve to a commit: $source_ref" >&2
exit 1
}
tag="bindings/go/$version"
if git rev-parse "$tag" >/dev/null 2>&1; then
echo "tag already exists: $tag" >&2
exit 1
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "source_ref=$source_ref" >> "$GITHUB_OUTPUT"
echo "source_sha=$(git rev-parse "$source_ref^{commit}")" >> "$GITHUB_OUTPUT"
build:
needs: validate
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
expected_file: libpaimon_c.linux.amd64.so.zst
- runner: ubuntu-24.04-arm
expected_file: libpaimon_c.linux.arm64.so.zst
- runner: macos-15-intel
expected_file: libpaimon_c.darwin.amd64.dylib.zst
- runner: macos-14
expected_file: libpaimon_c.darwin.arm64.dylib.zst
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.validate.outputs.source_sha }}
- name: Install Rust toolchain
run: |
rustup update stable
rustup default stable
- name: Cache Rust build outputs
uses: actions/cache@v6
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install zstd on Linux
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y zstd
- name: Install zstd on macOS
if: runner.os == 'macOS'
run: brew install zstd
- name: Build embedded shared library
working-directory: bindings/go
run: make build
- name: Verify packaged library
working-directory: bindings/go
shell: bash
run: |
test -s '${{ matrix.expected_file }}'
- name: Upload packaged library
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.expected_file }}
path: bindings/go/${{ matrix.expected_file }}
if-no-files-found: error
publish:
needs:
- validate
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ needs.validate.outputs.source_sha }}
- name: Download packaged libraries
uses: actions/download-artifact@v8
with:
path: bindings/go
merge-multiple: true
- name: Verify embedded assets
working-directory: bindings/go
shell: bash
run: |
for file in \
libpaimon_c.linux.amd64.so.zst \
libpaimon_c.linux.arm64.so.zst \
libpaimon_c.darwin.amd64.dylib.zst \
libpaimon_c.darwin.arm64.dylib.zst
do
test -s "$file"
done
- name: Create release tag commit
env:
TAG: ${{ needs.validate.outputs.tag }}
VERSION: ${{ needs.validate.outputs.version }}
SOURCE_REF: ${{ needs.validate.outputs.source_ref }}
SOURCE_SHA: ${{ needs.validate.outputs.source_sha }}
shell: bash
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add bindings/go/libpaimon_c.*.zst
if ! git diff --cached --quiet; then
git commit -m "bindings/go: release ${VERSION} (from ${SOURCE_REF}@${SOURCE_SHA})"
fi
git tag -a "$TAG" -m "Release Go binding ${VERSION} from ${SOURCE_REF}@${SOURCE_SHA}"
git push origin "refs/tags/$TAG"
- name: Create GitHub release
env:
TAG: ${{ needs.validate.outputs.tag }}
VERSION: ${{ needs.validate.outputs.version }}
GH_TOKEN: ${{ github.token }}
working-directory: bindings/go
run: |
gh release create "$TAG" \
--title "Release Go binding $VERSION" \
--generate-notes \
libpaimon_c.linux.amd64.so.zst \
libpaimon_c.linux.arm64.so.zst \
libpaimon_c.darwin.amd64.dylib.zst \
libpaimon_c.darwin.arm64.dylib.zst