-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: mode Changelog to do-release workflow (#251)
- Loading branch information
1 parent
44e7d80
commit 3614bef
Showing
2 changed files
with
90 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,11 @@ | |
# - Upload wheel to Test PyPi if build succeeds. (Future) | ||
# - Test install from Test PyPi. (Future) | ||
# - Upload wheel to PyPi if install test succeeds. (Future) | ||
# - Generate new CHANGELOG. | ||
# - Get next semantic version. | ||
# - Close old milestones. | ||
# - Create new minor version milestone. | ||
# - Create new major version milestone. | ||
name: Do Release Workflow | ||
|
||
on: | ||
|
@@ -37,7 +42,11 @@ jobs: | |
run: | | ||
pip install poetry | ||
echo "version=$(echo $(poetry version | cut -d' ' -f2))" >> $GITHUB_OUTPUT | ||
echo "do_release=1" >> $GITHUB_ENV | ||
if [[ $version != *"-rc"* ]]; then | ||
echo "do_release=1" >> $GITHUB_ENV | ||
echo "do_changelog=1" >> $GITHUB_ENV | ||
echo "do_milestones=1" >> $GITHUB_ENV | ||
fi | ||
- name: Build release | ||
id: build | ||
|
@@ -59,14 +68,6 @@ jobs: | |
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Print release info | ||
run: | | ||
echo ${{ steps.cutrelease.outputs.id }} | ||
echo ${{ steps.cutrelease.outputs.name }} | ||
echo ${{ steps.cutrelease.outputs.tag_name }} | ||
echo ${{ steps.cutrelease.outputs.html_url }} | ||
echo ${{ steps.cutrelease.outputs.upload_url }} | ||
- name: Upload wheel to GitHub release | ||
id: upload-wheel | ||
if: ${{ env.build_ok == 1 }} | ||
|
@@ -98,3 +99,76 @@ jobs: | |
# with: | ||
# user: __token__ | ||
# password: ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
- name: Generate release changelog | ||
uses: heinrichreimer/github-changelog-generator-action@master | ||
if: ${{ env.do_changelog == 1 }} | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
sinceTag: "v1.3.1" | ||
excludeTagsRegex: "-rc[0-9]" | ||
breakingLabel: "Breaking Changes" | ||
breakingLabels: "V: major" | ||
enhancementLabel: "Features" | ||
enhancementLabels: "P: enhancement" | ||
bugsLabel: "Bug Fixes" | ||
bugLabels: "P: bug" | ||
excludeLabels: "release" | ||
issues: false | ||
issuesWoLabels: false | ||
maxIssues: 100 | ||
pullRequests: true | ||
prWoLabels: false | ||
author: true | ||
unreleased: true | ||
compareLink: true | ||
stripGeneratorNotice: true | ||
verbose: true | ||
|
||
- name: Check if diff | ||
if: ${{ env.do_changelog == 1 }} | ||
continue-on-error: true | ||
run: > | ||
git diff --exit-code CHANGELOG.md && | ||
(echo "### No update" && exit 1) || (echo "### Commit update") | ||
- uses: EndBug/add-and-commit@v9 | ||
name: Commit and push if diff | ||
if: ${{ env.do_changelog == 1 }} | ||
with: | ||
add: CHANGELOG.md | ||
message: 'chore: update CHANGELOG.md for new release' | ||
author_name: GitHub Actions | ||
author_email: [email protected] | ||
committer_name: GitHub Actions | ||
committer_email: [email protected] | ||
push: true | ||
|
||
- name: Get next semantic version | ||
id: nextversion | ||
if: ${{ env.do_milestones == 1 }} | ||
uses: WyriHaximus/[email protected] | ||
with: | ||
version: ${{ steps.relversion.outputs.version }} | ||
|
||
- name: Close old milestone | ||
if: ${{ env.do_milestones == 1 }} | ||
uses: WyriHaximus/github-action-close-milestone@master | ||
with: | ||
number: ${{ steps.relversion.outputs.version }} | ||
|
||
- name: Create new minor release milestone | ||
if: ${{ env.do_milestones == 1 }} | ||
uses: WyriHaximus/[email protected] | ||
with: | ||
title: "${{ steps.nextversion.outputs.v_minor }}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create new major release milestone | ||
if: ${{ env.do_milestones == 1 }} | ||
uses: WyriHaximus/[email protected] | ||
with: | ||
title: "${{ steps.nextversion.outputs.v_major }}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,20 @@ | ||
# This workflow runs when a version tag is pushed. | ||
# | ||
# - Get new tag. | ||
# - If version tag: | ||
# - If release condidate tag: | ||
# - Build the pre-release. | ||
# - Cut GitHub pre-release. | ||
# - Upload wheel to pre-release. | ||
# - If release tag: | ||
# - Generate new CHANGELOG. | ||
# - Get next semantic version. | ||
# - Close old milestones. | ||
# - Create new minor version milestone. | ||
# - Create new major version milestone. | ||
name: Version Tag Workflow | ||
# - If release condidate tag: | ||
# - Build the pre-release. | ||
# - Cut GitHub pre-release. | ||
# - Upload wheel to pre-release. | ||
name: Prerelease Tag Workflow | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
update_changelog: | ||
name: Update Changelog | ||
cut_prerelease: | ||
name: Cut Pre-Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
|
@@ -37,9 +30,6 @@ jobs: | |
if [[ $tag == *"-rc"* ]]; then | ||
echo "do_prerelease=1" >> $GITHUB_ENV | ||
fi | ||
if [[ $tag != *"-rc"* ]]; then | ||
echo "do_changelog=1" >> $GITHUB_ENV | ||
fi | ||
echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT | ||
echo "New tag is: $tag" | ||
echo "GitHub ref: ${{ github.ref }}" | ||
|
@@ -71,100 +61,3 @@ jobs: | |
with: | ||
upload_url: ${{ steps.cutprerelease.outputs.upload_url }} | ||
asset_path: ./dist/*.whl | ||
|
||
- name: Generate release changelog | ||
uses: heinrichreimer/github-changelog-generator-action@master | ||
if: ${{ env.do_changelog == 1 }} | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
sinceTag: "v1.3.1" | ||
excludeTagsRegex: "-rc[0-9]" | ||
breakingLabel: "Breaking Changes" | ||
breakingLabels: "V: major" | ||
enhancementLabel: "Features" | ||
enhancementLabels: "P: enhancement" | ||
bugsLabel: "Bug Fixes" | ||
bugLabels: "P: bug" | ||
excludeLabels: "release" | ||
issues: false | ||
issuesWoLabels: false | ||
maxIssues: 100 | ||
pullRequests: true | ||
prWoLabels: false | ||
author: true | ||
unreleased: true | ||
compareLink: true | ||
stripGeneratorNotice: true | ||
verbose: true | ||
|
||
- name: Check if diff | ||
if: ${{ env.do_changelog == 1 }} | ||
continue-on-error: true | ||
run: > | ||
git diff --exit-code CHANGELOG.md && | ||
(echo "### No update" && exit 1) || (echo "### Commit update") | ||
- uses: EndBug/add-and-commit@v9 | ||
name: Commit and push if diff | ||
if: ${{ env.do_changelog == 1 }} | ||
with: | ||
add: CHANGELOG.md | ||
message: 'chore: update CHANGELOG.md for new release' | ||
author_name: GitHub Actions | ||
author_email: [email protected] | ||
committer_name: GitHub Actions | ||
committer_email: [email protected] | ||
push: true | ||
|
||
manage_milestones: | ||
name: Manage Milestones | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: master | ||
|
||
- name: Get new tag | ||
id: newversion | ||
run: | | ||
tag=${GITHUB_REF/refs\/tags\//} | ||
version=$(echo $tag | sed 's/-rc[0-9]*//') | ||
if [[ $tag != *"-rc"* ]]; then | ||
echo "do_milestones=1" >> $GITHUB_ENV | ||
echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT | ||
echo "version=$(echo $version)" >> $GITHUB_OUTPUT | ||
fi | ||
echo "New tag is: $tag" | ||
echo "New version is: $version" | ||
echo "GitHub ref: ${{ github.ref }}" | ||
- name: Get next semantic version | ||
id: nextversion | ||
if: ${{ env.do_milestones == 1 }} | ||
uses: WyriHaximus/[email protected] | ||
with: | ||
version: ${{ steps.newversion.outputs.version }} | ||
|
||
- name: Close old milestone | ||
if: ${{ env.do_milestones == 1 }} | ||
uses: WyriHaximus/github-action-close-milestone@master | ||
with: | ||
number: ${{ steps.newversion.outputs.version }} | ||
|
||
- name: Create new minor release milestone | ||
if: ${{ env.do_milestones == 1 }} | ||
uses: WyriHaximus/[email protected] | ||
with: | ||
title: "${{ steps.nextversion.outputs.v_minor }}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create new major release milestone | ||
if: ${{ env.do_milestones == 1 }} | ||
uses: WyriHaximus/[email protected] | ||
with: | ||
title: "${{ steps.nextversion.outputs.v_major }}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |