Skip to content

Create Release PR

Create Release PR #6

# This GitHub Workflow will create a new release branch that contains the updated C# project versions and changelog.
# The workflow will also create a PR that targets `dev` from the release branch.
name: Create Release PR
# This workflow is manually triggered when in preparation for a release. The workflow should be dispatched from the `dev` branch.
on:
workflow_dispatch:
jobs:
release-pr:
name: Release PR
runs-on: ubuntu-latest
steps:
# Checkout a full clone of the repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
# Install .NET8 which is needed for AutoVer
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Build solution to install not-yet published AutoVer package
- name: Build Solution
run: dotnet build
# Create NuGet package to install not-yet published AutoVer package
- name: Create NuGet Package
run: dotnet pack
# Install AutoVer to automate versioning and changelog creation
- name: Install AutoVer
run: dotnet tool install -g --add-source src/AutoVer/bin/Release autover
# Set up a git user to be able to run git commands later on
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub User"
# Create the release branch which will contain the version changes and updated changelog
- name: Create Release Branch
id: create-release-branch
run: |
branch=releases/next-release
git checkout -b $branch
echo "BRANCH=$branch" >> $GITHUB_OUTPUT
# Update the version of projects based on the change files
- name: Increment Version
run: autover version
# Update the changelog based on the change files
- name: Update Changelog
run: autover changelog
# Push the release branch up as well as the created tag
- name: Push Changes
run: |
branch=${{ steps.create-release-branch.outputs.BRANCH }}
git push origin $branch
git push origin $branch --tags
# Get the release name that will be used to create a PR
- name: Read Release Name
id: read-release-name
run: |
version=$(autover changelog --release-name)
echo "VERSION=$version" >> $GITHUB_OUTPUT
# Get the changelog that will be used to create a PR
- name: Read Changelog
id: read-changelog
run: |
changelog=$(autover changelog --output-to-console)
echo "CHANGELOG<<EOF"$'\n'"$changelog"$'\n'EOF >> "$GITHUB_OUTPUT"
# Create the Release PR and label it
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr_url="$(gh pr create --title "${{ steps.read-release-name.outputs.VERSION }}" --body "${{ steps.read-changelog.outputs.CHANGELOG }}" --base dev --head ${{ steps.create-release-branch.outputs.BRANCH }})"
gh label create "Release PR" --description "A Release PR that includes versioning and changelog changes" -c "#FF0000" -f
gh pr edit $pr_url --add-label "Release PR"