-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (82 loc) · 2.92 KB
/
update_version_and_release.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Version Update and Release
# Workflow Process Flow:
# 1. Trigger Conditions:
# - Manual execution (workflow_dispatch)
# 2. Environment Setup (Ubuntu, Python, Poetry)
# 3. Retrieve the current version
# 4. Update to the new version (patch, minor, or major)
# 5. Commit and push the changes
# 6. Create and push a new tag
# 7. Generate the changelog
# 8. Create a GitHub release
on:
workflow_dispatch:
inputs:
update_type:
description: "Type of version update"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
jobs:
update-version-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
token: ${{ secrets.PAT_FOR_PUSHES }}
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.13"
- name: Install poetry
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Get current version
id: current_version
run: echo "version=$(poetry version -s)" >> "$GITHUB_OUTPUT"
- name: Update version
id: update_version
run: |
poetry version ${{ github.event.inputs.update_type }}
echo "new_version=$(poetry version -s)" >> "$GITHUB_OUTPUT"
- name: Commit and push if changed
run: |
git add pyproject.toml
git commit -m ":wrench:Bump version to ${{ steps.update_version.outputs.new_version }}" || echo "No changes to commit"
git push
- name: Create and push new tag
run: |
git tag v${{ steps.update_version.outputs.new_version }}
git push --tags
- name: Generate changelog
id: changelog
run: |
changelog=$(git log --pretty=format:"- %s" v${{ steps.current_version.outputs.version }}..v${{ steps.update_version.outputs.new_version }})
{
echo "changelog<<EOF"
echo "$changelog"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create Release
uses: softprops/[email protected]
with:
tag_name: v${{ steps.update_version.outputs.new_version }}
name: repo-dispatch-event-sender-v${{ steps.update_version.outputs.new_version }}
body: |
## Changes in this Release
${{ steps.changelog.outputs.changelog }}
For full changes, see the [comparison view](${{ github.server_url }}/${{ github.repository }}/compare/v${{ steps.current_version.outputs.version }}..v${{ steps.update_version.outputs.new_version }})
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.PAT_FOR_PUSHES }}