Skip to content

Commit 3614bef

Browse files
authored
chore: mode Changelog to do-release workflow (#251)
1 parent 44e7d80 commit 3614bef

File tree

2 files changed

+90
-123
lines changed

2 files changed

+90
-123
lines changed

.github/workflows/do-release.yml

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
# - Upload wheel to Test PyPi if build succeeds. (Future)
1010
# - Test install from Test PyPi. (Future)
1111
# - Upload wheel to PyPi if install test succeeds. (Future)
12+
# - Generate new CHANGELOG.
13+
# - Get next semantic version.
14+
# - Close old milestones.
15+
# - Create new minor version milestone.
16+
# - Create new major version milestone.
1217
name: Do Release Workflow
1318

1419
on:
@@ -37,7 +42,11 @@ jobs:
3742
run: |
3843
pip install poetry
3944
echo "version=$(echo $(poetry version | cut -d' ' -f2))" >> $GITHUB_OUTPUT
40-
echo "do_release=1" >> $GITHUB_ENV
45+
if [[ $version != *"-rc"* ]]; then
46+
echo "do_release=1" >> $GITHUB_ENV
47+
echo "do_changelog=1" >> $GITHUB_ENV
48+
echo "do_milestones=1" >> $GITHUB_ENV
49+
fi
4150
4251
- name: Build release
4352
id: build
@@ -59,14 +68,6 @@ jobs:
5968
env:
6069
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6170

62-
- name: Print release info
63-
run: |
64-
echo ${{ steps.cutrelease.outputs.id }}
65-
echo ${{ steps.cutrelease.outputs.name }}
66-
echo ${{ steps.cutrelease.outputs.tag_name }}
67-
echo ${{ steps.cutrelease.outputs.html_url }}
68-
echo ${{ steps.cutrelease.outputs.upload_url }}
69-
7071
- name: Upload wheel to GitHub release
7172
id: upload-wheel
7273
if: ${{ env.build_ok == 1 }}
@@ -98,3 +99,76 @@ jobs:
9899
# with:
99100
# user: __token__
100101
# password: ${{ secrets.PYPI_API_TOKEN }}
102+
103+
- name: Generate release changelog
104+
uses: heinrichreimer/github-changelog-generator-action@master
105+
if: ${{ env.do_changelog == 1 }}
106+
with:
107+
token: ${{ secrets.GITHUB_TOKEN }}
108+
sinceTag: "v1.3.1"
109+
excludeTagsRegex: "-rc[0-9]"
110+
breakingLabel: "Breaking Changes"
111+
breakingLabels: "V: major"
112+
enhancementLabel: "Features"
113+
enhancementLabels: "P: enhancement"
114+
bugsLabel: "Bug Fixes"
115+
bugLabels: "P: bug"
116+
excludeLabels: "release"
117+
issues: false
118+
issuesWoLabels: false
119+
maxIssues: 100
120+
pullRequests: true
121+
prWoLabels: false
122+
author: true
123+
unreleased: true
124+
compareLink: true
125+
stripGeneratorNotice: true
126+
verbose: true
127+
128+
- name: Check if diff
129+
if: ${{ env.do_changelog == 1 }}
130+
continue-on-error: true
131+
run: >
132+
git diff --exit-code CHANGELOG.md &&
133+
(echo "### No update" && exit 1) || (echo "### Commit update")
134+
135+
- uses: EndBug/add-and-commit@v9
136+
name: Commit and push if diff
137+
if: ${{ env.do_changelog == 1 }}
138+
with:
139+
add: CHANGELOG.md
140+
message: 'chore: update CHANGELOG.md for new release'
141+
author_name: GitHub Actions
142+
author_email: [email protected]
143+
committer_name: GitHub Actions
144+
committer_email: [email protected]
145+
push: true
146+
147+
- name: Get next semantic version
148+
id: nextversion
149+
if: ${{ env.do_milestones == 1 }}
150+
uses: WyriHaximus/[email protected]
151+
with:
152+
version: ${{ steps.relversion.outputs.version }}
153+
154+
- name: Close old milestone
155+
if: ${{ env.do_milestones == 1 }}
156+
uses: WyriHaximus/github-action-close-milestone@master
157+
with:
158+
number: ${{ steps.relversion.outputs.version }}
159+
160+
- name: Create new minor release milestone
161+
if: ${{ env.do_milestones == 1 }}
162+
uses: WyriHaximus/[email protected]
163+
with:
164+
title: "${{ steps.nextversion.outputs.v_minor }}"
165+
env:
166+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167+
168+
- name: Create new major release milestone
169+
if: ${{ env.do_milestones == 1 }}
170+
uses: WyriHaximus/[email protected]
171+
with:
172+
title: "${{ steps.nextversion.outputs.v_major }}"
173+
env:
174+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/on-push-tag.yml

Lines changed: 7 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
# This workflow runs when a version tag is pushed.
22
#
33
# - Get new tag.
4-
# - If version tag:
5-
# - If release condidate tag:
6-
# - Build the pre-release.
7-
# - Cut GitHub pre-release.
8-
# - Upload wheel to pre-release.
9-
# - If release tag:
10-
# - Generate new CHANGELOG.
11-
# - Get next semantic version.
12-
# - Close old milestones.
13-
# - Create new minor version milestone.
14-
# - Create new major version milestone.
15-
name: Version Tag Workflow
4+
# - If release condidate tag:
5+
# - Build the pre-release.
6+
# - Cut GitHub pre-release.
7+
# - Upload wheel to pre-release.
8+
name: Prerelease Tag Workflow
169

1710
on:
1811
push:
1912
tags:
2013
- 'v*'
2114

2215
jobs:
23-
update_changelog:
24-
name: Update Changelog
16+
cut_prerelease:
17+
name: Cut Pre-Release
2518
runs-on: ubuntu-latest
2619
steps:
2720
- name: Checkout repository
@@ -37,9 +30,6 @@ jobs:
3730
if [[ $tag == *"-rc"* ]]; then
3831
echo "do_prerelease=1" >> $GITHUB_ENV
3932
fi
40-
if [[ $tag != *"-rc"* ]]; then
41-
echo "do_changelog=1" >> $GITHUB_ENV
42-
fi
4333
echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT
4434
echo "New tag is: $tag"
4535
echo "GitHub ref: ${{ github.ref }}"
@@ -71,100 +61,3 @@ jobs:
7161
with:
7262
upload_url: ${{ steps.cutprerelease.outputs.upload_url }}
7363
asset_path: ./dist/*.whl
74-
75-
- name: Generate release changelog
76-
uses: heinrichreimer/github-changelog-generator-action@master
77-
if: ${{ env.do_changelog == 1 }}
78-
with:
79-
token: ${{ secrets.GITHUB_TOKEN }}
80-
sinceTag: "v1.3.1"
81-
excludeTagsRegex: "-rc[0-9]"
82-
breakingLabel: "Breaking Changes"
83-
breakingLabels: "V: major"
84-
enhancementLabel: "Features"
85-
enhancementLabels: "P: enhancement"
86-
bugsLabel: "Bug Fixes"
87-
bugLabels: "P: bug"
88-
excludeLabels: "release"
89-
issues: false
90-
issuesWoLabels: false
91-
maxIssues: 100
92-
pullRequests: true
93-
prWoLabels: false
94-
author: true
95-
unreleased: true
96-
compareLink: true
97-
stripGeneratorNotice: true
98-
verbose: true
99-
100-
- name: Check if diff
101-
if: ${{ env.do_changelog == 1 }}
102-
continue-on-error: true
103-
run: >
104-
git diff --exit-code CHANGELOG.md &&
105-
(echo "### No update" && exit 1) || (echo "### Commit update")
106-
107-
- uses: EndBug/add-and-commit@v9
108-
name: Commit and push if diff
109-
if: ${{ env.do_changelog == 1 }}
110-
with:
111-
add: CHANGELOG.md
112-
message: 'chore: update CHANGELOG.md for new release'
113-
author_name: GitHub Actions
114-
author_email: [email protected]
115-
committer_name: GitHub Actions
116-
committer_email: [email protected]
117-
push: true
118-
119-
manage_milestones:
120-
name: Manage Milestones
121-
runs-on: ubuntu-latest
122-
steps:
123-
- name: Checkout repository
124-
uses: actions/checkout@v3
125-
with:
126-
fetch-depth: 0
127-
ref: master
128-
129-
- name: Get new tag
130-
id: newversion
131-
run: |
132-
tag=${GITHUB_REF/refs\/tags\//}
133-
version=$(echo $tag | sed 's/-rc[0-9]*//')
134-
if [[ $tag != *"-rc"* ]]; then
135-
echo "do_milestones=1" >> $GITHUB_ENV
136-
echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT
137-
echo "version=$(echo $version)" >> $GITHUB_OUTPUT
138-
fi
139-
echo "New tag is: $tag"
140-
echo "New version is: $version"
141-
echo "GitHub ref: ${{ github.ref }}"
142-
143-
- name: Get next semantic version
144-
id: nextversion
145-
if: ${{ env.do_milestones == 1 }}
146-
uses: WyriHaximus/[email protected]
147-
with:
148-
version: ${{ steps.newversion.outputs.version }}
149-
150-
- name: Close old milestone
151-
if: ${{ env.do_milestones == 1 }}
152-
uses: WyriHaximus/github-action-close-milestone@master
153-
with:
154-
number: ${{ steps.newversion.outputs.version }}
155-
156-
- name: Create new minor release milestone
157-
if: ${{ env.do_milestones == 1 }}
158-
uses: WyriHaximus/[email protected]
159-
with:
160-
title: "${{ steps.nextversion.outputs.v_minor }}"
161-
env:
162-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163-
164-
- name: Create new major release milestone
165-
if: ${{ env.do_milestones == 1 }}
166-
uses: WyriHaximus/[email protected]
167-
with:
168-
title: "${{ steps.nextversion.outputs.v_major }}"
169-
env:
170-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)