-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (76 loc) · 2.97 KB
/
bump.yml
File metadata and controls
84 lines (76 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: bump
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
workflow_call:
inputs:
bump:
required: true
type: string
secrets:
PLOTNIK_PAT:
required: true
jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Install tomato-toml
uses: baptiste0928/cargo-install@b687c656bda5733207e629b50a22bf68974a0305 # v3.3.2
with:
crate: tomato-toml
locked: true
- name: Calculate next version
id: version
run: |
current=$(tomato get workspace.package.version Cargo.toml)
IFS='.' read -r major minor patch <<< "$current"
case "${{ inputs.bump }}" in
major) next="$((major + 1)).0.0" ;;
minor) next="$major.$((minor + 1)).0" ;;
patch) next="$major.$minor.$((patch + 1))" ;;
esac
echo "current=$current" >> "$GITHUB_OUTPUT"
echo "next=$next" >> "$GITHUB_OUTPUT"
- name: Bump versions
run: |
next="${{ steps.version.outputs.next }}"
tomato set workspace.package.version "$next" Cargo.toml
tomato set workspace.dependencies.plotnik-core.version "$next" Cargo.toml
tomato set workspace.dependencies.plotnik-bytecode.version "$next" Cargo.toml
tomato set workspace.dependencies.plotnik-compiler.version "$next" Cargo.toml
tomato set workspace.dependencies.plotnik-vm.version "$next" Cargo.toml
tomato set workspace.dependencies.plotnik-langs.version "$next" Cargo.toml
tomato set workspace.dependencies.plotnik-lib.version "$next" Cargo.toml
# plotnik-cli has explicit plotnik-langs dep (default-features = false workaround)
tomato set dependencies.plotnik-langs.version "$next" crates/plotnik-cli/Cargo.toml
- name: Update lockfile
run: cargo check --workspace
- name: Create PR
env:
GH_TOKEN: ${{ secrets.PLOTNIK_PAT }}
run: |
next="${{ steps.version.outputs.next }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "bump/v$next"
git add Cargo.toml Cargo.lock crates/plotnik-cli/Cargo.toml
git commit -m "chore: Bump version to \`$next\`"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}"
git push -u origin "bump/v$next"
gh pr create \
--title "chore: Bump version to \`$next\`" \
--body "Bump ${{ inputs.bump }} version: \`${{ steps.version.outputs.current }}\` → \`$next\`"
gh pr merge --auto --squash