Added Release Workflow (#40) #1
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 Flow | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
version_type: | |
type: choice | |
description: 'Version type' | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 23.1.0 | |
- name: Install dependencies | |
run: npm install | |
- name: Bump version | |
run: | | |
VERSION_TYPE=${{ github.event.inputs.version_type }} | |
if [ "$VERSION_TYPE" == "patch" ]; then | |
NEW_VERSION=$(npm version patch -m "Release %s") | |
elif [ "$VERSION_TYPE" == "minor" ]; then | |
NEW_VERSION=$(npm version minor -m "Release %s") | |
elif [ "$VERSION_TYPE" == "major" ]; then | |
NEW_VERSION=$(npm version major -m "Release %s") | |
else | |
echo "Invalid version type: $VERSION_TYPE" | |
exit 1 | |
fi | |
echo "New version: $NEW_VERSION" | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Stash updated files and update package.json | |
run: | | |
npm i | |
git add . | |
- name: Create release branch | |
run: | | |
git checkout -b release/$NEW_VERSION | |
git push origin release/$NEW_VERSION | |
- name: Create tags | |
run: | | |
git push --tags | |
- name: Create release PR | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: release/$NEW_VERSION | |
title: 'Release $NEW_VERSION' | |
body: 'This PR merges the release branch for version $NEW_VERSION into main. Please fill in the release notes.' | |
base: main |