Skip to content

Commit

Permalink
chore: mode Changelog to do-release workflow (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
weibullguy authored Jul 10, 2023
1 parent 44e7d80 commit 3614bef
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 123 deletions.
92 changes: 83 additions & 9 deletions .github/workflows/do-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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: action@github.com
committer_name: GitHub Actions
committer_email: actions@github.com
push: true

- name: Get next semantic version
id: nextversion
if: ${{ env.do_milestones == 1 }}
uses: WyriHaximus/github-action-next-semvers@v1.2.1
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/github-action-create-milestone@v1.2.0
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/github-action-create-milestone@v1.2.0
with:
title: "${{ steps.nextversion.outputs.v_major }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121 changes: 7 additions & 114 deletions .github/workflows/on-push-tag.yml
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
Expand All @@ -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 }}"
Expand Down Expand Up @@ -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: action@github.com
committer_name: GitHub Actions
committer_email: actions@github.com
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/github-action-next-semvers@v1.2.1
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/github-action-create-milestone@v1.2.0
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/github-action-create-milestone@v1.2.0
with:
title: "${{ steps.nextversion.outputs.v_major }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 3614bef

Please sign in to comment.