Release #5
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
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
release: | |
description: 'The type of semantic version change to apply to the release.' | |
required: true | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
default: 'patch' | |
jobs: | |
create-new-release: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get previous version | |
id: previous-version | |
run: | | |
VERSION=`curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name'` | |
echo "got version $VERSION" | |
echo "VALUE=$VERSION" >> $GITHUB_OUTPUT | |
- name: Get next release version | |
id: next-version | |
run: | | |
array=($(echo ${{ steps.previous-version.outputs.VALUE }} | tr . '\n')) | |
target=2 | |
if [ ${{ inputs.release }} == "major" ]; then target=0; fi | |
if [ ${{ inputs.release }} == "minor" ]; then target=1; fi | |
array[$target]=$((array[$target]+1)) | |
if [ $target -lt 2 ]; then array[2]=0; fi | |
if [ $target -lt 1 ]; then array[1]=0; fi | |
output=$(IFS=. ; echo "${array[*]}") | |
echo "VALUE=$output" >> $GITHUB_OUTPUT | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.next-version.outputs.VALUE }} | |
release_name: ${{ steps.next-version.outputs.VALUE }} | |
draft: false | |
commitish: main # use the latest commit on main branch (including the new version) | |
prerelease: false | |
update-changelog: | |
needs: create-new-release | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Run make generate | |
run: make generate | |
- name: Generate version bump commit | |
run: | | |
git config user.name ${{ github.actor }} | |
git config user.email '${{ github.actor }}@users.noreply.github.com' | |
git commit -a -m "Update changelog for ${{ github.ref }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
title: '[chore] Update Changelog' | |
branch: update-changelog | |
delete-branch: true | |
labels: update-changelog |