-
Notifications
You must be signed in to change notification settings - Fork 17
98 lines (84 loc) · 3.41 KB
/
version-bump.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
88
89
90
91
92
93
94
95
96
97
98
###########################################################################################################
#
# This job creates a version bump branch based on main, and opens a PR from it.
#
# The branch will have the version bumped in all necessary parts of the code,
# and it will generate the NEWS.md content from the NEWS snippets.
#
# Organization members have the chance to add or modify the commits on the branch, if necessary.
#
# The job will also generate a tarball, and reference it in the PR's description.
#
# The job cannot be started, if there is an open PR with the version given.
#
# Manual steps:
# 1. Navigate to https://github.com/axoflow/axosyslog/actions.
# 2. Choose the "Version bump" job.
# 3. Click "Run workflow".
# 4. Fill the new release version, and click "Run workflow".
# 5. When the PR is opened, double check the changes, if necessary, add commits.
# 6. When the PR is merged, the "Draft release" job will automatically start.
#
###########################################################################################################
name: Version bump
permissions: write-all
on:
workflow_dispatch:
inputs:
release_version:
description: 'VERSION (<MAJOR>.<MINOR>.<PATCH>)'
required: true
jobs:
version-bump:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.PAT_FOR_ACTIONS }}
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
VERSION_BUMP_BRANCH: version/${{ github.event.inputs.release_version }}
CURRENT_RUN_URL: https://github.com/${{ github.repository_owner }}/axosyslog/actions/runs/${{ github.run_id }}
steps:
- name: Checkout AxoSyslog source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check existing PR
run: |
EXISTS=$(gh pr list --state open --head "${VERSION_BUMP_BRANCH}" --json "number" --jq ". | length")
if [ ${EXISTS} -ne 0 ]
then
echo "There is a PR already open for this version. Please close it before running this job."
exit 1
fi
- name: Configure git user
run: |
git config user.name "github-actions"
git config user.email "41898282+github-actions@users.noreply.github.com"
- name: Create git branch
run: |
git switch -c ${VERSION_BUMP_BRANCH}
- name: "DBLD: prepare-release"
run: |
./dbld/rules prepare-release VERSION=${RELEASE_VERSION}
git commit -a -s -m "version: bumped to ${RELEASE_VERSION}"
- name: Generate NEWS.md
run: |
./news/create-newsfile.py
git diff-index --quiet HEAD NEWS.md || git commit -a -s -m "NEWS: generate for ${RELEASE_VERSION}"
- name: "DBLD: release"
run: |
./dbld/rules release VERSION=${RELEASE_VERSION}
- name: Upload tarball
uses: actions/upload-artifact@v4
with:
name: axosyslog-${{ env.RELEASE_VERSION }}
path: dbld/release/${{ env.RELEASE_VERSION }}/axosyslog-${{ env.RELEASE_VERSION }}.tar.gz
- name: Open Pull Request
run: |
TITLE="Version: ${RELEASE_VERSION}"
DESCRIPTION="Tarball is available at: ${CURRENT_RUN_URL}"
git push --force origin ${VERSION_BUMP_BRANCH}
gh pr create \
--base "${GITHUB_REF}" \
--title "${TITLE}" \
--body "${DESCRIPTION}" \
--label "version-bump"