Skip to content

Draft new production release #2

Draft new production release

Draft new production release #2

name: "Draft new production release"
on:
workflow_dispatch:
inputs:
major_version:
description: 'The major version you want to release.'
required: true
minor_version:
description: 'The minor version you want to release.'
required: true
patch_version:
description: 'The patch version you want to release.'
required: true
jobs:
draft-new-release:
name: "Draft a new release"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create release branch
run: git checkout -b release/${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}
- name: Update Version Number
uses: RadovanPelka/github-action-json@v1.0.1
with:
path: semver.json
replaceWith: |
{
"major": "${{ github.event.inputs.major_version }}",
"minor": "${{ github.event.inputs.minor_version }}",
"patch": "${{ github.event.inputs.patch_version }}",
"build": "${{ github.run_number }}"
}
- name: Update changelog
uses: thomaseizinger/keep-a-changelog-new-release@1.3.0
with:
tag: ${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}
- name: Commit changelog and manifest files
id: make-commit
run: |
git config --global user.name "GitHub Action Bot"
git config --global user.email "no-reply@after-life.co"
git add CHANGELOG.md semver.json
git commit --message "Prepare release ${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}"
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Push new branch
run: git push origin release/${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}
- name: Create pull request
env:
GH_TOKEN: ${{ secrets.CREATE_PR_TOKEN }}
run: |
echo -e "Hi @${{ github.actor }}!\n\nThis PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.\nI've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.\n\nMerging this PR will create a GitHub release and upload any assets that are created as part of the release build." > msg.txt
export msg=$(cat msg.txt) ; gh pr create \
--head release/${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }} \
--base master \
--title "Release version ${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}" \
--reviewer ${{ github.actor }} \
--body "$msg"