Skip to content

Prepare Release Workflow #14

Prepare Release Workflow

Prepare Release Workflow #14

name: "Prepare Release Workflow"
# Manual trigger workflow to automatically setup a new release PR (built & publish on merge)
on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
concurrency:
group: "${{ github.workflow }}-${{ github.ref_name }}"
cancel-in-progress: true
jobs:
prepare_release:
name: "Prepare Release"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
token: ${{ secrets.GITBOT_TOKEN }}
fetch-depth: 0
- name: "Setup"
uses: ./.github/actions/setup
- name: "Increment package versions"
id: version
uses: ./.github/actions/increment-package-versions
with:
releaseType: '${{ inputs.releaseType }}'
- name: "Check build libs"
run: yarn build:libs
- name: "Git commit & push"
id: git
run: |
set -x # verbose
git config --global user.name "lumbot"
git config --global user.email "lumbot@users.noreply.github.com"
# Commit
commit="chore(release): release v${{ steps.version.outputs.nextVersion }}"
echo "commit=$commit" >> $GITHUB_OUTPUT
git commit -am "$commit"
# Push
git push origin "${{ steps.version.outputs.releaseBranch }}"
- name: "Create pull request"
uses: actions/github-script@v6
with:
github-token: '${{ secrets.GITBOT_TOKEN }}'
script: |
github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
base: 'master',
head: '${{ steps.version.outputs.releaseBranch }}',
title: '${{ steps.git.outputs.commit }}',
body: '# Release v${{ steps.version.outputs.nextVersion }}\n\n'
+ 'Review, test and merge to publish to NPM.\n\n'
+ 'Triggered by @${{ github.actor }}',
draft: false,
});