forked from crypto-com/cdcx-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (39 loc) · 1.41 KB
/
version-bump.yml
File metadata and controls
47 lines (39 loc) · 1.41 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
name: Version Bump
on:
workflow_dispatch:
inputs:
version:
description: "New version (e.g. 1.0.0)"
required: true
type: string
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate version format
run: |
if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Invalid version format. Expected semver (e.g. 1.3.0)"
exit 1
fi
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Update Cargo.toml workspace version
run: |
sed -i '/^\[workspace\.package\]/,/^\[/ s/^version = ".*"/version = "${{ inputs.version }}"/' Cargo.toml
- name: Update Cargo.lock
run: cargo update -w
- name: Update package.json version
run: |
jq --arg v "${{ inputs.version }}" '.version = $v' package.json > package.json.tmp
mv package.json.tmp package.json
- name: Commit, tag, and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock package.json
git commit -m "chore: bump version to ${{ inputs.version }}"
git tag "v${{ inputs.version }}"
git push
git push origin "v${{ inputs.version }}"