-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (74 loc) · 2.98 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
84
85
86
87
88
89
90
name: Bump version
on:
workflow_dispatch:
inputs:
bump_rule:
type: choice
description: How to bump the project's version (see `python-packages/input4MIPs-CVs/src/input4MIPs_CVs/cli/version.py bump --help`)
options:
- no-pre-release
- major
- minor
# Disabled because we always sit on pre-releases,
# hence same as no-pre-release.
# - micro
default: "no-pre-release"
jobs:
bump_version:
name: "Bump version"
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
permissions:
contents: write
env:
CI_COMMIT_EMAIL: "ci-runner@input4MIPs_CVs.invalid"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Thank you https://github.com/orgs/community/discussions/27028#discussioncomment-3254367
ssh-key: "${{ secrets.CI_KEY }}"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install the environment
run: |
which pip
pip install python-packages/input4MIPs-CVs
# Pin towncrier
# Particularly because of https://github.com/twisted/towncrier/issues/648
pip install 'towncrier==23.11.0'
- name: Bump
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$CI_COMMIT_EMAIL"
USER_INPUT=${{ github.event.inputs.bump_rule }}
BUMP_RULE=${USER_INPUT:-"no-pre-release"}
BASE_VERSION=`cat VERSION`
echo "Bumping from version $BASE_VERSION"
# Bump out of pre-release
python python-packages/input4MIPs-CVs/src/input4MIPs_CVs/cli/version.py bump "no-pre-release" --no-pre-release --repo-root-dir .
# Bump to new release
if [ "${BUMP_RULE}" != "no-pre-release" ]; then
python python-packages/input4MIPs-CVs/src/input4MIPs_CVs/cli/version.py bump "${BUMP_RULE}" --no-pre-release --repo-root-dir .
fi
NEW_VERSION=`cat VERSION`
echo "Bumping to version $NEW_VERSION"
# Build CHANGELOG
towncrier build --yes --version v$NEW_VERSION
# Commit, tag and push
echo $NEW_VERSION
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="${NEW_VERSION}"
# Bump to next pre-release
python python-packages/input4MIPs-CVs/src/input4MIPs_CVs/cli/version.py bump "micro" --pre-release --repo-root-dir .
NEW_VERSION=`cat VERSION`
echo "Bumping version $BASE_VERSION > $NEW_VERSION"
# Commit and push
git commit -a -m "bump(pre-release): version $BASE_VERSION > $NEW_VERSION"
git push