Skip to content

Rindo Production Release PR Creation #24

Rindo Production Release PR Creation

Rindo Production Release PR Creation #24

name: 'Rindo Production Release PR Creation'
on:
workflow_dispatch:
inputs:
version:
required: true
type: choice
description: Which version should be published?
options:
- prerelease # e.g: 1.0.0 -> 1.0.1-0
- prepatch # e.g: 1.0.0 -> 1.0.1-0
- preminor # e.g: 1.0.0 -> 1.1.0-0
- premajor # e.g: 1.0.0 -> 2.0.0-0
- patch # e.g: 1.0.0 -> 1.0.1
- minor # e.g: 1.0.0 -> 1.1.0
- major # e.g: 1.0.0 -> 2.0.0
base:
required: true
type: choice
description: Which base branch should be targeted?
default: main
options:
- main
- v3-maintenance
jobs:
create-rindo-release-pull-request:
name: Generate Rindo Release PR
runs-on: ubuntu-latest
steps:
# Log the input from GitHub Actions for easy traceability
- name: Log GitHub Input
run: |
echo "Version: ${{ inputs.version }}"
shell: bash
- name: Checkout Code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
# A depth of 0 gets the entire git history, which we'll want for things like checking all git history/tags.
# We need git history to generate the changelog; however, we don't know how deep to go.
# Since publishing is a one-off activity, just get everything.
fetch-depth: 0
ref: ${{ inputs.base }}
- name: Get Core Dependencies
uses: ./.github/workflows/actions/get-core-dependencies
# TODO(RINDO-927): Backport changes to the v3 branch
- name: Run Publish Preparation Script
run: npm run release.ci.prepare -- --version ${{ inputs.version }}
shell: bash
- name: Log Generated Changes
run: git --no-pager diff
shell: bash
- name: Generate Version String and Branch Name
id: name_gen
run: |
VERSION_STR=$(jq '.version' package.json | sed s/\"//g)
echo "VERSION_STR=$VERSION_STR" >> "$GITHUB_OUTPUT"
echo "BRANCH_NAME=release/$VERSION_STR-run-${{ github.run_number }}-${{ github.run_attempt }}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Print Version String and Branch Name
run: |
echo Version: ${{ steps.name_gen.outputs.VERSION_STR }}
echo Branch Name: ${{ steps.name_gen.outputs.BRANCH_NAME }}
shell: bash
- name: Create the Pull Request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
with:
# create a new pull request using the specified base branch
base: ${{ inputs.base }}
# specifies the name of the branch to create off of the base branch
branch: '${{ steps.name_gen.outputs.BRANCH_NAME }}'
# TODO(RINDO-928): Remove this once pipeline is 'ready'
draft: true
# create a commit message containing the semver version, prefixed with a 'v' - e.g. 'v4.1.0'
commit-message: 'v${{ steps.name_gen.outputs.VERSION_STR }}'
# set the title of the pull request, otherwise it'll default to generic message
title: 'Release v${{ steps.name_gen.outputs.VERSION_STR }}'
# the body of the pull request summary can be empty
body: ''