-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (68 loc) · 2.63 KB
/
bump.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
name: Bump version
on:
workflow_dispatch:
inputs:
bump_rule:
type: choice
description: How to bump the project's version (see https://github.com/carstencodes/pdm-bump#usage)
options:
- no-pre-release
# no micro because we always sit on a pre-release in main,
# so we would always use no-pre-release instead of micro
# - micro
- minor
- major
- "pre-release --pre alpha"
- "pre-release --pre beta"
- "pre-release --pre release-candidate"
required: true
jobs:
bump_version:
name: "Bump version and create changelog"
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
env:
CI_COMMIT_EMAIL: "[email protected]"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.9"
- name: Install pdm-bump
run: |
pdm self add pdm-bump
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
pdm-dependency-install-flags: "-G dev"
- name: Create bump and changelog
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$CI_COMMIT_EMAIL"
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
echo "Bumping from version $BASE_VERSION"
# Bump
pdm bump ${{ github.event.inputs.bump_rule }}
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
echo "Bumping to version $NEW_VERSION"
# Build CHANGELOG
pdm run towncrier build --yes --version v$NEW_VERSION
# Commit, tag and push
git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION"
git tag v$NEW_VERSION
git push && git push --tags
# Bump to alpha (so that future commits do not have the same
# version as the tagged commit)
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
# Bump to pre-release of next version
pdm bump pre-release --pre alpha
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
echo "Bumping version $BASE_VERSION > $NEW_VERSION"
# Commit and push
git commit -a -m "bump(pre-release): version $BASE_VERSION > $NEW_VERSION"
git push