Skip to content

Create pre-release branch #110

Create pre-release branch

Create pre-release branch #110

# Bump package version numbers and bundle changelogs into changelog file
name: Create pre-release branch
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch or tag to create pre-release from'
required: true
default: 'main'
bump_type:
description: 'Bump type'
required: true
type: choice
options:
- stable-major
- stable-minor
- stable-patch
- stable-remove-beta-suffix
- beta-release-major
- beta-release-minor
- beta-release-patch
- beta-release-beta
# cancel workflow when a newer version of the workflow is triggered on the same github ref
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# create pre-release branch for beta releases
create_pre-release:
name: Bump versions and make changelog for release
runs-on: ubuntu-latest
permissions: read-all
steps:
# Check-out repo
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Use a machine account when checking out. This is to workaround the issue were GitHub
# actions, when using the default account, cannot trigger other actions. And we want this
# action to trigger the regular CI pipeline on the created branch.
# This machine account is only for this PAT, pwd was created and thrown away
# If any update needed, create a new account, add access to the repo and generate a new PAT
token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
# Setup bot information for creating pull request
# Here we use the id from the github actions bot: https://api.github.com/users/better-informatics%5Bbot%5D
- name: Setup bot git information
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
# Check out onto desired branch or tag to create release from
- name: Checkout tag/branch
run: git checkout ${{ github.event.inputs.branch }}
# Ensure node version is great enough
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
# Try get node_modules from cache
- name: Restore node_modules from cache
uses: actions/cache@v3
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
# Install dependencies
- name: Install rush
run: npm install -g @microsoft/rush@$(jq -r '.rushVersion' "rush.json")
- name: Install dependencies
run: rush install --max-install-attempts 3
# ####################################################################
# Create pre-release branch
#
# Bump versions first so we can use the new version in the branch name.
- name: Bump beta release major package version
if: ${{ github.event.inputs.bump_type == 'beta-release-major' }}
run: node common/scripts/bump-beta-release-version.js major
- name: Bump beta release minor package version
if: ${{ github.event.inputs.bump_type == 'beta-release-minor' }}
run: node common/scripts/bump-beta-release-version.js minor
- name: Bump beta release patch package version
if: ${{ github.event.inputs.bump_type == 'beta-release-patch' }}
run: node common/scripts/bump-beta-release-version.js patch
- name: Bump beta release beta package version
if: ${{ github.event.inputs.bump_type == 'beta-release-beta' }}
run: node common/scripts/bump-beta-release-version.js beta
- name: Bump stable major package versions
if: ${{ github.event.inputs.bump_type == 'stable-major' }}
run: node common/scripts/bump-stable-version.js major
- name: Bump stable minor package versions
if: ${{ github.event.inputs.bump_type == 'stable-minor' }}
run: node common/scripts/bump-stable-version.js minor
- name: Bump stable patch package versions
if: ${{ github.event.inputs.bump_type == 'stable-patch' }}
run: node common/scripts/bump-stable-version.js patch
- name: Remove beta version from stable package versions
if: ${{ github.event.inputs.bump_type == 'stable-remove-beta-suffix' }}
run: node common/scripts/bump-stable-version.js remove-beta
# Retrieve new version so we can use it in the branch name.
- name: Retrieve new version from package.json
id: version
run: |
ver=$(jq -r .version packages/communication-react/package.json)
echo version: $ver
echo "version=$ver" >> $GITHUB_OUTPUT
- name: Hop into new branch before comitting changes
id: prereleasebranch
run: |
git checkout -b prerelease-${{github.event.inputs.bump_type}}/${{ steps.version.outputs.version }}
echo "prereleasebranch=prerelease-${{github.event.inputs.bump_type}}/${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
- name: Commit package version bump
run: |
git add .
git commit -m "${{github.event.inputs.bump_type}} version bump"
- name: Generate beta CHANGELOG
if: ${{ github.event.inputs.bump_type == 'beta-release-major' || github.event.inputs.bump_type == 'beta-release-minor' || github.event.inputs.bump_type == 'beta-release-patch' || github.event.inputs.bump_type == 'beta-release-beta' }}
run: node common/scripts/changelog/collect.mjs beta
- name: Generate stable CHANGELOG
if: ${{ github.event.inputs.bump_type == 'stable-major' || github.event.inputs.bump_type == 'stable-minor' || github.event.inputs.bump_type == 'stable-patch' || github.event.inputs.bump_type == 'stable-remove-beta-suffix' }}
run: node common/scripts/changelog/collect.mjs stable
- name: sanity check - ensure all package versions are consistent
run: rush ensure-consistent-versions
- name: Push new branch to remote
run: git push -u origin "${{ steps.prereleasebranch.outputs.prereleasebranch }}"
# ####################################################################
# Create a PR to groom the CHANGELOG
#
- name: Hop into new branch
id: groombranch
run: |
git checkout -b groom-changelog-${{github.event.inputs.bump_type}}/${{ steps.version.outputs.version }}
echo "groombranch=groom-changelog-${{github.event.inputs.bump_type}}/${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
- name: Add trivial changefile so CI does not complain about the CHANGELOG grooming PR
run: |
echo "Please create a changelog manually with message - Bumped versions for release"
echo "This is no longer possible due to changes to beachball. Use rushx changelog to create the file."
# Push groom changes
- name: Create groom file and push changes
run: |
echo 'Please groom the changelog and then delete me.' > GROOMME.md
git add .
git commit -m 'Create groom me file for groom changelog branch'
git push -u origin ${{ steps.groombranch.outputs.groombranch }}
- name: REMOVED - DO THIS MANUALLY! Create PR of changelog branch to pre-release branch
run: |
echo "Creating pull requests by GitHub Action is no longer supported per Microsoft Open Source Security Policy."
echo "Please create a pull request manually from ${{ steps.groombranch.outputs.groombranch }} to ${{ steps.prereleasebranch.outputs.prereleasebranch }}."
echo "In the PR description please include the following text: `Please groom CHANGELOG.md in this branch`."
echo "See example: https://github.com/Azure/communication-ui-library/pull/2694"