Skip to content

Commit 2ca0b46

Browse files
committed
ci(release): add tag-triggered multi-platform GitHub release workflow
1 parent 2c1169b commit 2ca0b46

1 file changed

Lines changed: 166 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
BINARY_NAME: tabularis-clickhouse-plugin
13+
14+
jobs:
15+
# ── 1. Prepare: update manifest.json version & generate CHANGELOG ──
16+
prepare:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
version: ${{ steps.version.outputs.version }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Extract version from tag
26+
id: version
27+
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
28+
29+
- name: Update manifest.json version
30+
run: |
31+
jq --arg v "${{ steps.version.outputs.version }}" '.version = $v' manifest.json > manifest.tmp.json
32+
mv manifest.tmp.json manifest.json
33+
34+
- name: Generate CHANGELOG.md
35+
id: changelog
36+
uses: orhun/git-cliff-action@v4
37+
with:
38+
config: cliff.toml
39+
args: --tag ${{ github.ref_name }}
40+
env:
41+
OUTPUT: CHANGELOG.md
42+
GITHUB_REPO: ${{ github.repository }}
43+
44+
- name: Commit version bump & changelog
45+
run: |
46+
git config user.name "github-actions[bot]"
47+
git config user.email "github-actions[bot]@users.noreply.github.com"
48+
git add manifest.json CHANGELOG.md
49+
git commit -m "chore(release): ${{ github.ref_name }}" || true
50+
git push origin HEAD:main
51+
52+
- name: Upload manifest as artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: manifest
56+
path: manifest.json
57+
58+
- name: Upload changelog as artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: changelog
62+
path: CHANGELOG.md
63+
64+
# ── 2. Build matrix ────────────────────────────────────────────────
65+
build:
66+
needs: prepare
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
include:
71+
- target: x86_64-unknown-linux-gnu
72+
os: ubuntu-latest
73+
platform: linux-x64
74+
- target: aarch64-unknown-linux-gnu
75+
os: ubuntu-latest
76+
platform: linux-arm64
77+
- target: x86_64-apple-darwin
78+
os: macos-latest
79+
platform: darwin-x64
80+
- target: aarch64-apple-darwin
81+
os: macos-latest
82+
platform: darwin-arm64
83+
- target: x86_64-pc-windows-msvc
84+
os: windows-latest
85+
platform: win-x64
86+
87+
runs-on: ${{ matrix.os }}
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- name: Download manifest artifact
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: manifest
95+
96+
- name: Install Rust toolchain
97+
uses: dtolnay/rust-toolchain@stable
98+
with:
99+
targets: ${{ matrix.target }}
100+
101+
- name: Install cross-compilation tools (Linux aarch64)
102+
if: matrix.target == 'aarch64-unknown-linux-gnu'
103+
run: |
104+
sudo apt-get update
105+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
106+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
107+
108+
- name: Cache cargo registry & build
109+
uses: actions/cache@v4
110+
with:
111+
path: |
112+
~/.cargo/registry
113+
~/.cargo/git
114+
target
115+
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
116+
restore-keys: ${{ matrix.target }}-cargo-
117+
118+
- name: Build release binary
119+
run: cargo build --release --target ${{ matrix.target }}
120+
121+
- name: Package (unix)
122+
if: runner.os != 'Windows'
123+
run: |
124+
mkdir staging
125+
cp target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} staging/
126+
cp manifest.json staging/
127+
cd staging && zip -r ../clickhouse-plugin-${{ matrix.platform }}.zip .
128+
129+
- name: Package (windows)
130+
if: runner.os == 'Windows'
131+
shell: pwsh
132+
run: |
133+
New-Item -ItemType Directory -Force -Path staging
134+
Copy-Item "target\${{ matrix.target }}\release\${{ env.BINARY_NAME }}.exe" staging\
135+
Copy-Item "manifest.json" staging\
136+
Compress-Archive -Path "staging\*" -DestinationPath "clickhouse-plugin-${{ matrix.platform }}.zip"
137+
138+
- name: Upload artifact
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: clickhouse-plugin-${{ matrix.platform }}
142+
path: clickhouse-plugin-${{ matrix.platform }}.zip
143+
144+
# ── 3. Create GitHub Release ───────────────────────────────────────
145+
release:
146+
needs: [prepare, build]
147+
runs-on: ubuntu-latest
148+
steps:
149+
- name: Download all artifacts
150+
uses: actions/download-artifact@v4
151+
with:
152+
path: artifacts
153+
merge-multiple: true
154+
155+
- name: Download changelog
156+
uses: actions/download-artifact@v4
157+
with:
158+
name: changelog
159+
160+
- name: Create GitHub Release
161+
uses: softprops/action-gh-release@v2
162+
with:
163+
name: ${{ github.ref_name }}
164+
body_path: CHANGELOG.md
165+
files: artifacts/*.zip
166+
generate_release_notes: false

0 commit comments

Comments
 (0)