Skip to content

Commit 3c99263

Browse files
authored
feat: Add publish workflow (#324)
1 parent 11c2df3 commit 3c99263

8 files changed

Lines changed: 119 additions & 42 deletions

File tree

.github/workflows/bump.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Bump Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: "Version bump type"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
workflow_call:
16+
inputs:
17+
bump:
18+
required: true
19+
type: string
20+
21+
jobs:
22+
bump:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write
26+
pull-requests: write
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Install tomato-toml
32+
run: cargo install tomato-toml --locked
33+
34+
- name: Calculate next version
35+
id: version
36+
run: |
37+
current=$(tomato get workspace.package.version Cargo.toml)
38+
IFS='.' read -r major minor patch <<< "$current"
39+
case "${{ inputs.bump }}" in
40+
major) next="$((major + 1)).0.0" ;;
41+
minor) next="$major.$((minor + 1)).0" ;;
42+
patch) next="$major.$minor.$((patch + 1))" ;;
43+
esac
44+
echo "current=$current" >> "$GITHUB_OUTPUT"
45+
echo "next=$next" >> "$GITHUB_OUTPUT"
46+
47+
- name: Bump versions
48+
run: |
49+
next="${{ steps.version.outputs.next }}"
50+
tomato set workspace.package.version "$next" Cargo.toml
51+
tomato set workspace.dependencies.plotnik-core.version "$next" Cargo.toml
52+
tomato set workspace.dependencies.plotnik-langs.version "$next" Cargo.toml
53+
tomato set workspace.dependencies.plotnik-lib.version "$next" Cargo.toml
54+
# plotnik-cli has explicit plotnik-langs dep (default-features = false workaround)
55+
tomato set dependencies.plotnik-langs.version "$next" crates/plotnik-cli/Cargo.toml
56+
57+
- name: Update lockfile
58+
run: cargo check --workspace
59+
60+
- name: Create PR
61+
env:
62+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
run: |
64+
next="${{ steps.version.outputs.next }}"
65+
git config user.name "github-actions[bot]"
66+
git config user.email "github-actions[bot]@users.noreply.github.com"
67+
git checkout -b "bump/v$next"
68+
git add Cargo.toml Cargo.lock crates/plotnik-cli/Cargo.toml
69+
git commit -m "chore: Bump version to \`$next\`"
70+
git push -u origin "bump/v$next"
71+
gh pr create \
72+
--title "chore: Bump version to \`$next\`" \
73+
--body "Bump ${{ inputs.bump }} version: \`${{ steps.version.outputs.current }}\` → \`$next\`"

.github/workflows/release.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: release
22

33
on:
4-
push:
5-
tags:
6-
- "v[0-9]+.*"
4+
release:
5+
types: [published]
76

87
env:
98
CARGO_TERM_COLOR: always
@@ -37,6 +36,7 @@ jobs:
3736
publish:
3837
needs: verify
3938
runs-on: ubuntu-latest
39+
environment: crates-io
4040
steps:
4141
- name: Checkout
4242
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
@@ -49,16 +49,11 @@ jobs:
4949
with:
5050
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
5151

52-
github-release:
52+
bump-patch:
5353
needs: publish
54-
runs-on: ubuntu-latest
54+
uses: ./.github/workflows/bump.yml
55+
with:
56+
bump: patch
5557
permissions:
5658
contents: write
57-
steps:
58-
- name: Checkout
59-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
60-
61-
- name: Create GitHub Release
62-
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
63-
with:
64-
generate_release_notes: true
59+
pull-requests: write

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
[workspace]
2-
32
resolver = "2"
4-
53
members = ["crates/plotnik-cli", "crates/plotnik-lib", "crates/plotnik-langs", "crates/plotnik-core"]
4+
5+
[workspace.package]
6+
version = "0.2.0"
7+
license = "Apache-2.0"
8+
repository = "https://github.com/plotnik-lang/plotnik"
9+
edition = "2024"
10+
11+
[workspace.dependencies]
12+
plotnik-core = { path = "crates/plotnik-core", version = "0.2.0" }
13+
plotnik-langs = { path = "crates/plotnik-langs", version = "0.2.0" }
14+
plotnik-lib = { path = "crates/plotnik-lib", version = "0.2.0" }

crates/plotnik-cli/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "plotnik"
3-
version = "0.2.0"
4-
edition = "2024"
5-
license = "Apache-2.0"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
67
description = "CLI for plotnik - typed query language for tree-sitter AST"
7-
repository = "https://github.com/plotnik-lang/plotnik"
88
documentation = "https://docs.rs/plotnik"
99
keywords = ["tree-sitter", "query", "ast", "parser", "cli"]
1010
categories = ["command-line-utilities", "development-tools"]
@@ -234,9 +234,9 @@ lang-zsh = ["plotnik-langs/lang-zsh"]
234234

235235
[dependencies]
236236
clap = { version = "4.5", features = ["derive"] }
237-
plotnik-core = { version = "0.2", path = "../plotnik-core" }
238-
plotnik-langs = { version = "0.2", path = "../plotnik-langs", default-features = false }
239-
plotnik-lib = { version = "0.2", path = "../plotnik-lib" }
237+
plotnik-core.workspace = true
238+
plotnik-langs = { path = "../plotnik-langs", version = "0.2.0", default-features = false }
239+
plotnik-lib.workspace = true
240240
arborium-tree-sitter = "2.5.0"
241241
serde = { version = "1.0", features = ["derive"] }
242242
serde_json = "1.0"

crates/plotnik-core/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "plotnik-core"
3-
version = "0.2.0"
4-
edition = "2024"
5-
license = "Apache-2.0"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
67
description = "Core data structures for Plotnik"
7-
repository = "https://github.com/plotnik-lang/plotnik"
88

99
[lints.rust]
1010
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }

crates/plotnik-langs/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "plotnik-langs"
3-
version = "0.2.0"
4-
edition = "2024"
5-
license = "Apache-2.0"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
67
description = "Tree-sitter language bindings for Plotnik query language"
7-
repository = "https://github.com/plotnik-lang/plotnik"
88
documentation = "https://docs.rs/plotnik-langs"
99
keywords = ["tree-sitter", "parser", "languages"]
1010
categories = ["parsing", "development-tools"]
@@ -233,7 +233,7 @@ lang-zsh = ["dep:arborium-zsh"]
233233

234234
[dependencies]
235235
paste = "1.0"
236-
plotnik-core = { version = "0.2", path = "../plotnik-core" }
236+
plotnik-core.workspace = true
237237
postcard = { version = "1", features = ["alloc"] }
238238
arborium-tree-sitter = "2.5.0"
239239
arborium-ada = { version = "2.5.0", optional = true }
@@ -337,7 +337,7 @@ arborium-zsh = { version = "2.5.0", optional = true }
337337

338338
[build-dependencies]
339339
cargo_metadata = "0.23"
340-
plotnik-core = { version = "0.2", path = "../plotnik-core" }
340+
plotnik-core.workspace = true
341341
postcard = { version = "1", features = ["alloc"] }
342342
serde = "1"
343343
serde_json = "1"

crates/plotnik-lib/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "plotnik-lib"
3-
version = "0.2.0"
4-
edition = "2024"
5-
license = "Apache-2.0"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
67
description = "Typed query language for tree-sitter AST"
7-
repository = "https://github.com/plotnik-lang/plotnik"
88
documentation = "https://docs.rs/plotnik-lib"
99
readme = "../../README.md"
1010
keywords = ["tree-sitter", "query", "ast", "parser"]
@@ -23,8 +23,8 @@ thiserror = "2.0.17"
2323
arborium-tree-sitter = "2.5.0"
2424
crc32fast = "1.4"
2525
memmap2 = "0.9"
26-
plotnik-core = { version = "0.2", path = "../plotnik-core" }
27-
plotnik-langs = { version = "0.2", path = "../plotnik-langs", optional = true }
26+
plotnik-core.workspace = true
27+
plotnik-langs = { workspace = true, optional = true }
2828

2929
[features]
3030
default = ["plotnik-langs"]

0 commit comments

Comments
 (0)