Skip to content

Commit bdbcb7f

Browse files
committed
fix: update release workflow to use version input and improve tagging process
1 parent a32df8e commit bdbcb7f

5 files changed

Lines changed: 73 additions & 209 deletions

File tree

.github/workflows/release.yaml

Lines changed: 22 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
name: Build and Release
22

33
on:
4-
push:
5-
tags: ["*"]
6-
pull_request:
74
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to release (e.g., 0.1.0)"
8+
required: true
9+
type: string
810

911
permissions:
10-
contents: read
11-
id-token: write # For PyPI OIDC publishing
12-
attestations: write # For artifact attestation
12+
contents: write # Changed to write for tagging
13+
id-token: write
14+
attestations: write
1315

1416
jobs:
1517
build-wheels-linux:
1618
runs-on: ${{ matrix.platform.runner }}
1719
steps:
1820
- uses: actions/checkout@v4
19-
- name: Wait for tests to succeed
20-
uses: lewagon/wait-on-check-action@v1.4.1
21-
with:
22-
ref: ${{ github.ref }}
23-
check-name: test
24-
repo-token: ${{ secrets.GITHUB_TOKEN }}
25-
wait-interval: 10
2621
- uses: actions/setup-python@v5
2722
with:
2823
python-version: 3.x
@@ -41,7 +36,7 @@ jobs:
4136
working-directory: kiru-py
4237
target: ${{ matrix.platform.target }}
4338
args: --release --out dist --find-interpreter
44-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
39+
sccache: "true"
4540
manylinux: auto
4641
- name: Upload wheels
4742
uses: actions/upload-artifact@v4
@@ -68,13 +63,6 @@ jobs:
6863
runs-on: ${{ matrix.platform.runner }}
6964
steps:
7065
- uses: actions/checkout@v4
71-
- name: Wait for tests to succeed
72-
uses: lewagon/wait-on-check-action@v1.4.1
73-
with:
74-
ref: ${{ github.ref }}
75-
check-name: test
76-
repo-token: ${{ secrets.GITHUB_TOKEN }}
77-
wait-interval: 10
7866
- uses: actions/setup-python@v5
7967
with:
8068
python-version: 3.x
@@ -93,7 +81,7 @@ jobs:
9381
working-directory: kiru-py
9482
target: ${{ matrix.platform.target }}
9583
args: --release --out dist --find-interpreter
96-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
84+
sccache: "true"
9785
manylinux: musllinux_1_2
9886
- name: Upload wheels
9987
uses: actions/upload-artifact@v4
@@ -116,13 +104,6 @@ jobs:
116104
runs-on: ${{ matrix.platform.runner }}
117105
steps:
118106
- uses: actions/checkout@v4
119-
- name: Wait for tests to succeed
120-
uses: lewagon/wait-on-check-action@v1.4.1
121-
with:
122-
ref: ${{ github.ref }}
123-
check-name: test
124-
repo-token: ${{ secrets.GITHUB_TOKEN }}
125-
wait-interval: 10
126107
- uses: actions/setup-python@v5
127108
with:
128109
python-version: 3.x
@@ -142,7 +123,7 @@ jobs:
142123
working-directory: kiru-py
143124
target: ${{ matrix.platform.target }}
144125
args: --release --out dist --find-interpreter
145-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
126+
sccache: "true"
146127
- name: Upload wheels
147128
uses: actions/upload-artifact@v4
148129
with:
@@ -160,13 +141,6 @@ jobs:
160141
runs-on: ${{ matrix.platform.runner }}
161142
steps:
162143
- uses: actions/checkout@v4
163-
- name: Wait for tests to succeed
164-
uses: lewagon/wait-on-check-action@v1.4.1
165-
with:
166-
ref: ${{ github.ref }}
167-
check-name: test
168-
repo-token: ${{ secrets.GITHUB_TOKEN }}
169-
wait-interval: 10
170144
- uses: actions/setup-python@v5
171145
with:
172146
python-version: 3.x
@@ -185,7 +159,7 @@ jobs:
185159
working-directory: kiru-py
186160
target: ${{ matrix.platform.target }}
187161
args: --release --out dist --find-interpreter
188-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
162+
sccache: "true"
189163
- name: Upload wheels
190164
uses: actions/upload-artifact@v4
191165
with:
@@ -203,13 +177,6 @@ jobs:
203177
runs-on: ubuntu-latest
204178
steps:
205179
- uses: actions/checkout@v4
206-
- name: Wait for tests to succeed
207-
uses: lewagon/wait-on-check-action@v1.4.1
208-
with:
209-
ref: ${{ github.ref }}
210-
check-name: test
211-
repo-token: ${{ secrets.GITHUB_TOKEN }}
212-
wait-interval: 10
213180
- uses: actions/setup-python@v5
214181
with:
215182
python-version: 3.x
@@ -229,13 +196,6 @@ jobs:
229196
runs-on: ubuntu-latest
230197
steps:
231198
- uses: actions/checkout@v4
232-
- name: Wait for tests to succeed
233-
uses: lewagon/wait-on-check-action@v1.4.1
234-
with:
235-
ref: ${{ github.ref }}
236-
check-name: test
237-
repo-token: ${{ secrets.GITHUB_TOKEN }}
238-
wait-interval: 10
239199
- name: Install Rust
240200
uses: dtolnay/rust-toolchain@stable
241201
- name: Package kiru-core
@@ -248,7 +208,6 @@ jobs:
248208

249209
release:
250210
runs-on: ubuntu-latest
251-
if: startsWith(github.ref, 'refs/tags/')
252211
needs:
253212
[
254213
build-wheels-linux,
@@ -264,18 +223,13 @@ jobs:
264223
attestations: write
265224
steps:
266225
- uses: actions/checkout@v4
267-
- name: Wait for tests to succeed
268-
uses: lewagon/wait-on-check-action@v1.4.1
269226
with:
270-
ref: ${{ github.ref }}
271-
check-name: test
272-
repo-token: ${{ secrets.GITHUB_TOKEN }}
273-
wait-interval: 10
227+
fetch-depth: 0 # Need full history for tagging
274228
- uses: actions/download-artifact@v4
275229
- name: Generate artifact attestation
276230
uses: actions/attest-build-provenance@v2
277231
with:
278-
subject-path: "wheels-*/*"
232+
subject-path: "wheels-*/*,crate-kiru-core/*"
279233
- name: Publish kiru-core to crates.io
280234
env:
281235
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
@@ -291,6 +245,14 @@ jobs:
291245
- name: Create GitHub Release
292246
uses: softprops/action-gh-release@v2
293247
with:
248+
tag_name: v${{ inputs.version }}
249+
name: Release v${{ inputs.version }}
294250
files: |
295251
wheels-*/*
296252
crate-kiru-core/*
253+
- name: Create and push tag
254+
run: |
255+
git config user.name "github-actions[bot]"
256+
git config user.email "github-actions[bot]@users.noreply.github.com"
257+
git tag v${{ inputs.version }} -m "Release v${{ inputs.version }}"
258+
git push origin v${{ inputs.version }}

.github/workflows/test.yaml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ name: Test
33
on:
44
push:
55
branches: [main]
6-
tags: ["*"]
76
pull_request:
87
workflow_dispatch:
98

109
jobs:
1110
check-version:
12-
name: python
11+
name: check-version
1312
runs-on: ubuntu-latest
13+
outputs:
14+
version: ${{ steps.get-version.outputs.version }}
1415
steps:
1516
- uses: actions/checkout@v5
1617
- name: Install uv
1718
uses: astral-sh/setup-uv@v6
18-
19-
- name: Run tests
19+
- name: Run version checks
2020
run: uv run utils/check_version_sync.py && uv run utils/check_version_newer.py
21+
- name: Get version
22+
id: get-version
23+
run: |
24+
VERSION=$(uv run utils/get_version.py)
25+
echo "version=$VERSION" >> $GITHUB_OUTPUT
26+
echo "Version: $VERSION"
2127
2228
test:
2329
name: test
@@ -38,37 +44,50 @@ jobs:
3844
target
3945
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
4046
restore-keys: ${{ runner.os }}-cargo-
41-
4247
- name: Format check
4348
run: cargo fmt --all -- --check
44-
4549
- name: Clippy
4650
run: cargo clippy --workspace --all-targets -- -D warnings
47-
4851
- name: Rust tests
4952
run: cargo test --workspace
50-
5153
- name: Install uv
5254
run: curl -LsSf https://astral.sh/uv/install.sh | sh
53-
5455
- name: Set up Python
5556
uses: actions/setup-python@v5
5657
with:
5758
python-version: "3.13"
58-
5959
- name: Install maturin
6060
run: uv tool install maturin
61-
6261
- name: Build and install package
6362
working-directory: kiru-py
6463
run: |
6564
uv venv
6665
source .venv/bin/activate
6766
maturin develop --release
68-
6967
- name: Run Python tests
7068
working-directory: kiru-py
7169
run: |
7270
source .venv/bin/activate
7371
uv sync --dev
7472
uv run pytest python/test.py
73+
74+
trigger-release:
75+
name: trigger-release
76+
runs-on: ubuntu-latest
77+
needs: [check-version, test]
78+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
79+
steps:
80+
- name: Trigger release workflow
81+
uses: actions/github-script@v7
82+
with:
83+
github-token: ${{ secrets.GITHUB_TOKEN }}
84+
script: |
85+
await github.rest.actions.createWorkflowDispatch({
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
workflow_id: 'release.yaml',
89+
ref: 'main',
90+
inputs: {
91+
version: '${{ needs.check-version.outputs.version }}'
92+
}
93+
});

justfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ check-version:
1010
bump-version version:
1111
uv run utils/bump_version.py {{version}}
1212

13-
tag-version *args:
14-
uv run utils/tag_version.py {{args}}

utils/get_version.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# utils/tag_version.py
2+
# /// script
3+
# dependencies = [
4+
# "tomlkit",
5+
# ]
6+
# ///
7+
from pathlib import Path
8+
9+
import tomlkit
10+
11+
12+
def get_current_version() -> str:
13+
"""Get version from kiru-py/Cargo.toml"""
14+
py_toml = Path("kiru-py/Cargo.toml")
15+
with open(py_toml) as f:
16+
return tomlkit.load(f)["package"]["version"]
17+
18+
19+
if __name__ == "__main__":
20+
print(get_current_version())

0 commit comments

Comments
 (0)