Skip to content

Commit 96afa93

Browse files
committed
Add GitHub Actions CI
- MainDistributionPipeline: builds and tests on Linux, macOS Intel, macOS ARM - Release: manual workflow to create tagged releases with artifacts - CMakeLists.txt: auto-build Rust library if missing
1 parent e2e13c1 commit 96afa93

File tree

3 files changed

+211
-0
lines changed

3 files changed

+211
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# Build, test and (optionally) release the extension
3+
#
4+
name: Main Extension Distribution Pipeline
5+
on:
6+
push:
7+
pull_request:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' && github.sha || '' }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
name: Build (${{ matrix.duckdb_arch }})
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- os: ubuntu-latest
23+
duckdb_arch: linux_amd64
24+
rust_target: x86_64-unknown-linux-gnu
25+
- os: macos-13
26+
duckdb_arch: osx_amd64
27+
rust_target: x86_64-apple-darwin
28+
- os: macos-14
29+
duckdb_arch: osx_arm64
30+
rust_target: aarch64-apple-darwin
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
submodules: recursive
36+
fetch-depth: 0
37+
38+
- name: Install Rust
39+
uses: dtolnay/rust-action@stable
40+
with:
41+
targets: ${{ matrix.rust_target }}
42+
43+
- name: Build Rust library
44+
run: |
45+
cd yardstick-rs
46+
cargo build --release
47+
48+
- name: Build extension
49+
run: make release
50+
51+
- name: Test extension
52+
run: make test
53+
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: yardstick-${{ matrix.duckdb_arch }}
58+
path: build/release/extension/yardstick/yardstick.duckdb_extension

.github/workflows/Release.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#
2+
# Manual release workflow - triggered via GitHub UI to create tagged releases
3+
#
4+
name: Release
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g., v0.1.0)'
11+
required: true
12+
type: string
13+
prerelease:
14+
description: 'Mark as pre-release'
15+
required: false
16+
type: boolean
17+
default: false
18+
19+
jobs:
20+
create-tag:
21+
name: Create release tag
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
outputs:
26+
tag_created: ${{ steps.tag.outputs.created }}
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Validate version format
33+
run: |
34+
if [[ ! "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
35+
echo "Error: Version must match format v0.0.0 or v0.0.0-suffix"
36+
exit 1
37+
fi
38+
39+
- name: Check if tag exists
40+
id: check
41+
run: |
42+
if git rev-parse "${{ inputs.version }}" >/dev/null 2>&1; then
43+
echo "Tag ${{ inputs.version }} already exists"
44+
echo "exists=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "exists=false" >> $GITHUB_OUTPUT
47+
fi
48+
49+
- name: Create and push tag
50+
id: tag
51+
if: steps.check.outputs.exists != 'true'
52+
run: |
53+
git config user.name "github-actions[bot]"
54+
git config user.email "github-actions[bot]@users.noreply.github.com"
55+
git tag -a "${{ inputs.version }}" -m "Release ${{ inputs.version }}"
56+
git push origin "${{ inputs.version }}"
57+
echo "created=true" >> $GITHUB_OUTPUT
58+
59+
build:
60+
name: Build (${{ matrix.duckdb_arch }})
61+
needs: create-tag
62+
runs-on: ${{ matrix.os }}
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
include:
67+
- os: ubuntu-latest
68+
duckdb_arch: linux_amd64
69+
rust_target: x86_64-unknown-linux-gnu
70+
- os: macos-13
71+
duckdb_arch: osx_amd64
72+
rust_target: x86_64-apple-darwin
73+
- os: macos-14
74+
duckdb_arch: osx_arm64
75+
rust_target: aarch64-apple-darwin
76+
77+
steps:
78+
- uses: actions/checkout@v4
79+
with:
80+
submodules: recursive
81+
fetch-depth: 0
82+
83+
- name: Install Rust
84+
uses: dtolnay/rust-action@stable
85+
with:
86+
targets: ${{ matrix.rust_target }}
87+
88+
- name: Build Rust library
89+
run: |
90+
cd yardstick-rs
91+
cargo build --release
92+
93+
- name: Build extension
94+
run: make release
95+
96+
- name: Test extension
97+
run: make test
98+
99+
- name: Upload artifact
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: yardstick-${{ matrix.duckdb_arch }}
103+
path: build/release/extension/yardstick/yardstick.duckdb_extension
104+
105+
release:
106+
name: Create GitHub Release
107+
needs: [create-tag, build]
108+
runs-on: ubuntu-latest
109+
permissions:
110+
contents: write
111+
steps:
112+
- uses: actions/checkout@v4
113+
114+
- name: Download all artifacts
115+
uses: actions/download-artifact@v4
116+
with:
117+
path: artifacts
118+
119+
- name: Prepare release assets
120+
run: |
121+
mkdir -p release_assets
122+
for dir in artifacts/*/; do
123+
platform=$(basename "$dir")
124+
for ext in "$dir"*.duckdb_extension*; do
125+
[ -f "$ext" ] || continue
126+
filename=$(basename "$ext")
127+
newname="${filename/.duckdb_extension/-${platform}.duckdb_extension}"
128+
cp "$ext" "release_assets/$newname"
129+
done
130+
done
131+
ls -la release_assets/
132+
133+
- name: Create release
134+
uses: softprops/action-gh-release@v2
135+
with:
136+
tag_name: ${{ inputs.version }}
137+
name: ${{ inputs.version }}
138+
prerelease: ${{ inputs.prerelease }}
139+
generate_release_notes: true
140+
files: release_assets/*

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ set(YARDSTICK_RS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/yardstick-rs")
1414
set(YARDSTICK_LIB "${YARDSTICK_RS_DIR}/target/release/libyardstick.a")
1515
set(YARDSTICK_INCLUDE "${YARDSTICK_RS_DIR}/include")
1616

17+
# Build Rust library if it doesn't exist
18+
if(NOT EXISTS ${YARDSTICK_LIB})
19+
message(STATUS "Building Rust library...")
20+
execute_process(
21+
COMMAND cargo build --release
22+
WORKING_DIRECTORY ${YARDSTICK_RS_DIR}
23+
RESULT_VARIABLE CARGO_RESULT
24+
)
25+
if(NOT CARGO_RESULT EQUAL 0)
26+
message(FATAL_ERROR "Failed to build Rust library")
27+
endif()
28+
endif()
29+
1730
# Include Rust library headers
1831
include_directories(${YARDSTICK_INCLUDE})
1932

0 commit comments

Comments
 (0)