-
-
Notifications
You must be signed in to change notification settings - Fork 23
93 lines (84 loc) · 2.98 KB
/
bumpversion.yaml
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
name: Auto-bump the version
on:
pull_request:
types: [closed]
branches: [master]
workflow_dispatch:
jobs:
bumpversion:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip' # caching pip dependencies
- name: Install requirements
run: |
python -m pip install generate-changelog bump-my-version
- name: Git check
run: |
git config --global user.email "[email protected]"
git config --global user.name "Testing Git"
git --version
git config --list
- name: Generate the changelog and get the release hint
id: generate-changelog
run: |
RELEASE_KIND=$(generate-changelog --output release-hint)
echo "::notice::Suggested release type is: ${RELEASE_KIND}"
echo "RELEASE_KIND=$RELEASE_KIND" >> $GITHUB_ENV
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
echo "PACKAGE=false" >> $GITHUB_ENV
- name: Bump Version auto
if: ${{ github.event_name != 'workflow_dispatch' }}
shell: bash
run: |
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
REVISION=$(git describe --tags --long | awk -F- '{print $2}')
export PR_NUMBER REVISION
case "$RELEASE_KIND" in
major|minor|patch)
bump-my-version bump "$RELEASE_KIND"
if [[ BUMPVERSION_DRY_RUN == "false" ]]; then
git push
git push --tags
echo "PACKAGE=true" >> $GITHUB_ENV
fi
;;
dev)
echo "Intentionally not bumping version for dev release"
;;
esac
- name: Bump Version manual
if: ${{ github.event_name == 'workflow_dispatch' }}
shell: bash
run: |
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
REVISION=$(git describe --tags --long | awk -F- '{print $2}')
export PR_NUMBER REVISION
case "$RELEASE_KIND" in
major|minor|patch)
bump-my-version bump "$RELEASE_KIND"
if [[ BUMPVERSION_DRY_RUN == "false" ]]; then
git push
git push --tags
echo "PACKAGE=true" >> $GITHUB_ENV
fi
;;
dev)
bump-my-version bump -v --no-commit "$RELEASE_KIND"
echo "PACKAGE=true" >> $GITHUB_ENV
;;
esac
- name: Package
if: ${{ env.PACKAGE == 'true' }}
uses: hynek/build-and-inspect-python-package@v1
- name: Upload dev release to PyPI
if: ${{ env.PACKAGE == 'true' && env.RELEASE_KIND == 'dev' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}