-
Notifications
You must be signed in to change notification settings - Fork 11
84 lines (73 loc) · 2.61 KB
/
version-bump.yml
File metadata and controls
84 lines (73 loc) · 2.61 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: Version Bump
on:
workflow_dispatch:
inputs:
bump_type:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
create_release:
description: 'Create release after bump'
required: false
type: boolean
default: false
permissions:
contents: write
jobs:
bump-version:
name: Bump Version
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.bump.outputs.new_version }}
old_version: ${{ steps.bump.outputs.old_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
id: bump
run: |
# Get current version
OLD_VERSION=$(cat VERSION_CLI | tr -d '[:space:]')
echo "old_version=$OLD_VERSION" >> $GITHUB_OUTPUT
# Run bump script
chmod +x ./scripts/bump-version.sh
./scripts/bump-version.sh ${{ inputs.bump_type }}
# Get new version
NEW_VERSION=$(cat VERSION_CLI | tr -d '[:space:]')
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Version bumped from $OLD_VERSION to $NEW_VERSION"
- name: Commit version bump
run: |
git add VERSION_CLI Cargo.toml Cargo.lock
git commit -m "chore: bump version to ${{ steps.bump.outputs.new_version }}"
git push origin HEAD
- name: Create and push tag
if: inputs.create_release
run: |
git tag "v${{ steps.bump.outputs.new_version }}"
git push origin "v${{ steps.bump.outputs.new_version }}"
notify:
name: Summary
runs-on: ubuntu-latest
needs: bump-version
steps:
- name: Summary
run: |
echo "## Version Bump Complete! 🎉" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| | |" >> $GITHUB_STEP_SUMMARY
echo "|---|---|" >> $GITHUB_STEP_SUMMARY
echo "| **Previous Version** | ${{ needs.bump-version.outputs.old_version }} |" >> $GITHUB_STEP_SUMMARY
echo "| **New Version** | ${{ needs.bump-version.outputs.new_version }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Bump Type** | ${{ inputs.bump_type }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Release Created** | ${{ inputs.create_release }} |" >> $GITHUB_STEP_SUMMARY