Skip to content

Commit 32c5a1a

Browse files
build(bindings): package complete legal metadata (#561)
1 parent 5f9f184 commit 32c5a1a

17 files changed

Lines changed: 2450 additions & 40 deletions

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# Generated TSVs keep trailing empty columns.
22
*.tsv text eol=lf linguist-generated=true whitespace=-blank-at-eol
3+
4+
# Legal files are verified byte-for-byte.
5+
LICENSE text eol=lf
6+
NOTICE text eol=lf
7+
**/LICENSE text eol=lf
8+
**/NOTICE text eol=lf
9+
**/THIRD-PARTY-LICENSES*.html text eol=lf linguist-generated=true
10+
third-party-licenses/* text eol=lf
11+
12+
# Generated wheel legal files must never enter the ASF source archive.
13+
bindings/python/licenses/** export-ignore

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,72 @@ jobs:
3939
runs-on: ubuntu-latest
4040
steps:
4141
- uses: actions/checkout@v7
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Detect release license inputs
46+
id: release_license_inputs
47+
shell: bash
48+
env:
49+
EVENT_NAME: ${{ github.event_name }}
50+
BEFORE_SHA: ${{ github.event.before }}
51+
BASE_REF: ${{ github.base_ref }}
52+
run: |
53+
set -euo pipefail
54+
if [[ "$EVENT_NAME" == "pull_request" ]]; then
55+
base="origin/$BASE_REF"
56+
elif [[ -n "$BEFORE_SHA" && ! "$BEFORE_SHA" =~ ^0+$ ]] && \
57+
git cat-file -e "$BEFORE_SHA^{commit}"; then
58+
base="$BEFORE_SHA"
59+
else
60+
echo "changed=true" >> "$GITHUB_OUTPUT"
61+
exit 0
62+
fi
63+
64+
if git diff --quiet "$base" HEAD -- \
65+
.gitattributes \
66+
LICENSE \
67+
NOTICE \
68+
':(glob)**/LICENSE' \
69+
':(glob)**/LICENSE.*' \
70+
':(glob)**/NOTICE' \
71+
':(glob)**/NOTICE.*' \
72+
Cargo.lock \
73+
about.hbs \
74+
about.toml \
75+
bindings/go/LICENSE \
76+
bindings/go/NOTICE \
77+
':(glob)bindings/go/THIRD-PARTY-LICENSES.*.html' \
78+
bindings/python/licenses \
79+
bindings/python/THIRD-PARTY-LICENSES.html \
80+
scripts/release_licenses.py \
81+
third-party-licenses \
82+
':(glob)**/Cargo.toml'; then
83+
echo "changed=false" >> "$GITHUB_OUTPUT"
84+
else
85+
echo "changed=true" >> "$GITHUB_OUTPUT"
86+
fi
4287
4388
- name: Validate .asf.yaml
4489
run: python3 scripts/validate_asf_yaml.py
4590

4691
- name: Check License Header
4792
uses: apache/skywalking-eyes/header@v0.8.0
4893

94+
- name: Test release artifact verifiers
95+
run: python3 -m unittest discover -s scripts/tests -p 'test_*.py'
96+
4997
- name: Install cargo-deny
5098
uses: taiki-e/install-action@a6b2e2dcd845ddd7f509ce4f3ed3d922b80cc5d9 # v2.84.0
5199
with:
52100
tool: cargo-deny@0.19.6
53101

102+
- name: Install cargo-about
103+
if: steps.release_license_inputs.outputs.changed == 'true'
104+
uses: taiki-e/install-action@a6b2e2dcd845ddd7f509ce4f3ed3d922b80cc5d9 # v2.84.0
105+
with:
106+
tool: cargo-about@0.9.1
107+
54108
- name: Fetch locked dependencies
55109
run: cargo fetch --locked
56110

@@ -60,6 +114,10 @@ jobs:
60114
- name: Verify dependency reports
61115
run: python3 scripts/dependencies.py verify
62116

117+
- name: Verify release license files
118+
if: steps.release_license_inputs.outputs.changed == 'true'
119+
run: python3 scripts/release_licenses.py --check
120+
63121
- name: Format
64122
run: cargo fmt --all -- --check
65123

.github/workflows/release-go-binding.yml

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ on:
3636
type: string
3737

3838
permissions:
39-
contents: write
39+
contents: read
4040

4141
jobs:
4242
validate:
@@ -103,12 +103,20 @@ jobs:
103103
include:
104104
- runner: ubuntu-latest
105105
expected_file: libpaimon_c.linux.amd64.so.zst
106+
rust_target: x86_64-unknown-linux-gnu
107+
license_file: THIRD-PARTY-LICENSES.linux.amd64.html
106108
- runner: ubuntu-24.04-arm
107109
expected_file: libpaimon_c.linux.arm64.so.zst
110+
rust_target: aarch64-unknown-linux-gnu
111+
license_file: THIRD-PARTY-LICENSES.linux.arm64.html
108112
- runner: macos-15-intel
109113
expected_file: libpaimon_c.darwin.amd64.dylib.zst
114+
rust_target: x86_64-apple-darwin
115+
license_file: THIRD-PARTY-LICENSES.darwin.amd64.html
110116
- runner: macos-14
111117
expected_file: libpaimon_c.darwin.arm64.dylib.zst
118+
rust_target: aarch64-apple-darwin
119+
license_file: THIRD-PARTY-LICENSES.darwin.arm64.html
112120

113121
steps:
114122
- uses: actions/checkout@v7
@@ -120,6 +128,10 @@ jobs:
120128
rustup update stable
121129
rustup default stable
122130
131+
- uses: actions/setup-python@v6
132+
with:
133+
python-version: "3.11"
134+
123135
- name: Cache Rust build outputs
124136
uses: actions/cache@v6
125137
with:
@@ -131,6 +143,11 @@ jobs:
131143
target/
132144
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
133145

146+
- name: Install cargo-about
147+
uses: taiki-e/install-action@a6b2e2dcd845ddd7f509ce4f3ed3d922b80cc5d9 # v2.84.0
148+
with:
149+
tool: cargo-about@0.9.1
150+
134151
- name: Install zstd on Linux
135152
if: runner.os == 'Linux'
136153
run: sudo apt-get update && sudo apt-get install -y zstd
@@ -143,48 +160,69 @@ jobs:
143160
working-directory: bindings/go
144161
run: make build
145162

146-
- name: Verify packaged library
147-
working-directory: bindings/go
163+
- name: Stage and verify packaged library
148164
shell: bash
149165
run: |
150-
test -s '${{ matrix.expected_file }}'
166+
mkdir -p release/go
167+
cargo fetch --locked
168+
python3 scripts/release_licenses.py \
169+
--generate-go-report \
170+
'${{ matrix.rust_target }}' \
171+
release/go
172+
cp 'bindings/go/${{ matrix.expected_file }}' release/go/
173+
python3 scripts/verify_go_release_artifacts.py \
174+
--artifacts-dir release/go \
175+
--target '${{ matrix.rust_target }}'
151176
152177
- name: Upload packaged library
153178
uses: actions/upload-artifact@v7
154179
with:
155180
name: ${{ matrix.expected_file }}
156-
path: bindings/go/${{ matrix.expected_file }}
181+
path: |
182+
release/go/${{ matrix.expected_file }}
183+
release/go/${{ matrix.license_file }}
157184
if-no-files-found: error
158185

159186
publish:
160187
needs:
161188
- validate
162189
- build
163190
runs-on: ubuntu-latest
191+
permissions:
192+
contents: write
164193
steps:
165194
- uses: actions/checkout@v7
166195
with:
167196
fetch-depth: 0
168197
ref: ${{ needs.validate.outputs.source_sha }}
169198

199+
- uses: actions/setup-python@v6
200+
with:
201+
python-version: "3.11"
202+
203+
- name: Install cargo-about
204+
uses: taiki-e/install-action@a6b2e2dcd845ddd7f509ce4f3ed3d922b80cc5d9 # v2.84.0
205+
with:
206+
tool: cargo-about@0.9.1
207+
208+
- name: Fetch locked release inputs
209+
run: cargo fetch --locked
210+
211+
- name: Install artifact verification tools
212+
run: sudo apt-get update && sudo apt-get install -y file zstd
213+
170214
- name: Download packaged libraries
171215
uses: actions/download-artifact@v8
172216
with:
173-
path: bindings/go
217+
path: release/go
174218
merge-multiple: true
175219

176-
- name: Verify embedded assets
177-
working-directory: bindings/go
220+
- name: Generate and verify release legal files
178221
shell: bash
179222
run: |
180-
for file in \
181-
libpaimon_c.linux.amd64.so.zst \
182-
libpaimon_c.linux.arm64.so.zst \
183-
libpaimon_c.darwin.amd64.dylib.zst \
184-
libpaimon_c.darwin.arm64.dylib.zst
185-
do
186-
test -s "$file"
187-
done
223+
python3 scripts/release_licenses.py \
224+
--generate-go-release release/go
225+
python3 scripts/verify_go_release_artifacts.py --artifacts-dir release/go
188226
189227
- name: Create release tag commit
190228
env:
@@ -197,7 +235,17 @@ jobs:
197235
git config user.name 'github-actions[bot]'
198236
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
199237
200-
git add bindings/go/libpaimon_c.*.zst
238+
cp release/go/libpaimon_c.*.zst bindings/go/
239+
cp \
240+
release/go/LICENSE \
241+
release/go/NOTICE \
242+
release/go/THIRD-PARTY-LICENSES.*.html \
243+
bindings/go/
244+
git add \
245+
bindings/go/libpaimon_c.*.zst \
246+
bindings/go/LICENSE \
247+
bindings/go/NOTICE \
248+
bindings/go/THIRD-PARTY-LICENSES.*.html
201249
202250
if ! git diff --cached --quiet; then
203251
git commit -m "bindings/go: release ${VERSION} (from ${SOURCE_REF}@${SOURCE_SHA})"
@@ -211,12 +259,18 @@ jobs:
211259
TAG: ${{ needs.validate.outputs.tag }}
212260
VERSION: ${{ needs.validate.outputs.version }}
213261
GH_TOKEN: ${{ github.token }}
214-
working-directory: bindings/go
262+
working-directory: release/go
215263
run: |
216264
gh release create "$TAG" \
217265
--title "Release Go binding $VERSION" \
218266
--generate-notes \
267+
LICENSE \
268+
NOTICE \
219269
libpaimon_c.linux.amd64.so.zst \
220270
libpaimon_c.linux.arm64.so.zst \
221271
libpaimon_c.darwin.amd64.dylib.zst \
222-
libpaimon_c.darwin.arm64.dylib.zst
272+
libpaimon_c.darwin.arm64.dylib.zst \
273+
THIRD-PARTY-LICENSES.linux.amd64.html \
274+
THIRD-PARTY-LICENSES.linux.arm64.html \
275+
THIRD-PARTY-LICENSES.darwin.amd64.html \
276+
THIRD-PARTY-LICENSES.darwin.arm64.html

0 commit comments

Comments
 (0)