-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (59 loc) · 1.94 KB
/
bump-version.yml
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
name: Bump version
run-name: Bump version (${{ github.event.inputs.bump_rule }})
on:
workflow_dispatch:
inputs:
bump_rule:
description: 'Bump rule'
required: true
default: 'patch'
type: choice
options:
- 'patch'
- 'minor'
- 'major'
env:
PYTHON_VERSION: "3.11"
jobs:
bump-version:
name: Bump version
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_version: ${{ steps.bump-version.outputs.new_version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Bump version
id: bump-version
run: |
new_version=$(poetry version --short ${{ github.event.inputs.bump_rule }})
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
echo "Bumped version to v$new_version" >> $GITHUB_STEP_SUMMARY
- name: Commit and push
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "Bump version to v${{ steps.bump-version.outputs.new_version }}"
new_branch: "bump-version/v${{ steps.bump-version.outputs.new_version }}"
create-pull-request:
name: Create pull request if on main
runs-on: ubuntu-latest
needs: bump-version
if: github.ref == 'refs/heads/main'
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Create pull request if on main
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr create --repo ${{ github.repository }} --base main --head "bump-version/v${{ needs.bump-version.outputs.new_version }}" --title "Bump version to v${{ needs.bump-version.outputs.new_version }}" --body "Bump version to v${{ needs.bump-version.outputs.new_version }}"