release-prepare #10
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: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'latest' | |
- name: Install dependencies | |
run: npm install | |
- name: Bump the firmware-action version in NPM-related files | |
id: update_npm_version | |
run: | | |
VERSION=$( npm version "${{ github.event.inputs.version }}" --no-git-tag-version | sed 's/v//g' ) | |
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" | |
- name: Update invoke-action.mjs | |
run: | | |
sed -i -E "s/const\s*VERSION\s*=\s*.*/const VERSION = '${{ steps.update_npm_version.outputs.version }}';/g" dist/invoke-action.mjs | |
- name: Update main.go | |
run: | | |
sed -i -E 's/const firmwareActionVersion = .*/const firmwareActionVersion = "v${{ steps.update_npm_version.outputs.version }}"/g' action/main.go | |
- name: Update Taskfile.yml | |
run: | | |
sed -i -E "s/SEMVER: .*/SEMVER: '${{ steps.update_npm_version.outputs.version }}'/g" Taskfile.yml | |
- name: Create pull request | |
id: create_pr | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: release/${{ steps.update_npm_version.outputs.version }} | |
commit-message: 'chore(action): bump version to ${{ steps.update_npm_version.outputs.version }}' | |
title: 'Release: ${{ steps.update_npm_version.outputs.version }} Pull Request' | |
body: 'Prepare for next release' | |
assignees: 'AtomicFS' | |
reviewers: 'AtomicFS' |