-
Notifications
You must be signed in to change notification settings - Fork 13
98 lines (86 loc) · 3.08 KB
/
Copy pathbump_version.yml
File metadata and controls
98 lines (86 loc) · 3.08 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Bump version
permissions:
contents: write # Grants write access to repository contents (required for creating releases)
pull-requests: write
on:
workflow_call:
inputs:
bump-type:
description: 'The type of bump to perform'
required: true
type: string
default: 'patch'
outputs:
bumped:
description: 'Whether the version was bumped'
value: ${{ jobs.bump.outputs.bumped }}
previous-version:
description: 'The previous version'
value: ${{ jobs.bump.outputs.previous-version }}
current-version:
description: 'The current version'
value: ${{ jobs.bump.outputs.current-version }}
workflow_dispatch:
inputs:
bump-type:
description: 'The type of bump to perform'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
- release
jobs:
bump:
runs-on: ubuntu-latest
outputs:
bumped: ${{ steps.bump.outputs.bumped }}
previous-version: ${{ steps.bump.outputs.previous-version }}
current-version: ${{ steps.bump.outputs.current-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0 # Required for tags history
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
activate-environment: "true"
python-version: '3.12'
enable-cache: true
- name: Install bump-my-version
run: |
uv pip install bump-my-version
- name: Setup git user
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Bump version
id: bump
run: |
echo "previous-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT
bump-my-version bump ${{ inputs.bump-type }} --commit
([[ $? -gt 0 ]] && echo "bumped=false" || echo "bumped=true") >> $GITHUB_OUTPUT
echo "current-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT
- name: Check
if: steps.bump.outputs.bumped == 'true'
run: |
echo "Version was bumped from ${{ steps.bump.outputs.previous-version }} to ${{ steps.bump.outputs.current-version }}!"
- name: Push changes
if: steps.bump.outputs.bumped == 'true' && github.ref_name != 'main'
run: |
git push
git push --tags
- name: Create Pull Request
if: steps.bump.outputs.bumped == 'true' && github.ref_name == 'main'
uses: peter-evans/create-pull-request@v8
with:
title: "chore: bump version to ${{ steps.bump.outputs.current-version }}"
body: |
Automated version bump from `${{ steps.bump.outputs.previous-version }}` to `${{ steps.bump.outputs.current-version }}`.
Bump type: `${{ inputs.bump-type }}`
branch: bump-version/${{ steps.bump.outputs.current-version }}
base: main