release-prepare #15
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
--- | |
# Update versions and create release PR | |
# Source: https://www.thisdot.co/blog/tag-and-release-your-project-with-github-actions-workflows | |
# | |
# For detailed description see "release.yml" | |
name: release-prepare | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version bump' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
permissions: | |
contents: write # To push new branch | |
pull-requests: write # To create a pull request | |
jobs: | |
release-prepare: | |
name: version_bump | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get cocogitto | |
run: | | |
cargo install --locked cocogitto | |
# Bump version | |
- name: Bump the firmware-action version | |
id: update_version | |
run: | | |
VERSION=$( cog bump --dry-run "--${{ github.event.inputs.version }}" 2>/dev/null | grep -E '^v' ) | |
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" | |
- name: Update main.go | |
run: | | |
sed -i -E 's/const firmwareActionVersion = .*/const firmwareActionVersion = "v${{ steps.update_version.outputs.version }}"/g' action/main.go | |
- name: Update Taskfile.yml | |
run: | | |
sed -i -E "s/SEMVER: .*/SEMVER: '${{ steps.update_version.outputs.version }}'/g" Taskfile.yml | |
- name: Update action.yml | |
run: | | |
sed -i -E "s/version=v[a-zA-Z0-9\.]+/version='${{ steps.update_version.outputs.version }}'/g" action.yml | |
- name: Update changelog | |
run: | | |
cog changelog > CHANGELOG.md | |
- name: Create pull request | |
id: create_pr | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: release/${{ steps.update_version.outputs.version }} | |
commit-message: 'chore(action): bump version to ${{ steps.update_version.outputs.version }}' | |
title: 'Release: ${{ steps.update_version.outputs.version }} Pull Request' | |
body: 'Prepare for next release' | |
assignees: 'AtomicFS' | |
reviewers: 'AtomicFS' |