Skip to content

Draft new production release #8

Draft new production release

Draft new production release #8

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: Afterlife-Guide/[email protected]
with:
path: semver.json
major-version: ${{ github.event.inputs.major_version }}
minor-version: ${{ github.event.inputs.minor_version }}
patch-version: ${{ github.event.inputs.patch_version }}
build-version: ${{ github.run_number }}
- name: Update changelog
uses: thomaseizinger/[email protected]
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 "[email protected]"
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"