-
Notifications
You must be signed in to change notification settings - Fork 4
63 lines (61 loc) · 2.59 KB
/
prepare-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
name: create-release-candidate
on:
workflow_dispatch:
inputs:
version_part:
description: The part of the version to update (patch, minor or major)
type: choice
options:
- patch
- minor
- major
default: 'patch'
required: true
jobs:
prepare-release:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
env:
PYTHON_PACKAGE: kedro_pandera
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Validate inputs
run: |
echo "INPUT_VERSION_PART: ${{ github.event.inputs.version_part }}"
- name: Bump the version number # bump2version is a maintained fork of original bumpversion
id: bump_version
run: |
pip install bump-my-version
bump-my-version bump ${{ github.event.inputs.version_part }}
echo "package_version=$(cat $PYTHON_PACKAGE/__init__.py | grep -Po '\d+\.\d+\.\d+')" >> $GITHUB_OUTPUT
- name: Update the CHANGELOG according to 'Keep a Changelog' guidelines
uses: thomaseizinger/keep-a-changelog-new-release@v1
with:
version: ${{ steps.bump_version.outputs.package_version }}
- name: Create a new release branch
run: |
git config user.name github-actions
git config user.email [email protected]
git checkout -b release-${{ steps.bump_version.outputs.package_version }}
git push -u origin release-${{ steps.bump_version.outputs.package_version }}
- name: Commit the changes
run: |
git commit -am "Bump version and CHANGELOG for release ${{ steps.bump_version.outputs.package_version }}"
git push
- name: Open a PR to merge the release to main
id: open_pr
run: |
gh pr create -B main -H release-${{ steps.bump_version.outputs.package_version }} --title "Release ${{ steps.bump_version.outputs.package_version }}" --body "Bump version and CHANGELOG for next release." --assignee "${{ github.repository_owner }}"
echo "pull_request_number=$(gh pr list --base main --json number,createdAt --jq 'sort_by(.createdAt) | reverse | .[0].number')" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Change the commit message to add PR number
run: |
git commit -a --amend -m ":rocket: Bump version and CHANGELOG for release ${{ steps.bump_version.outputs.package_version }} (#${{ steps.open_pr.outputs.pull_request_number }})"
git push -f