Skip to content

Draft new production release #7

Draft new production release

Draft new production release #7

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/SemVer.Action@1.0.4.6
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/keep-a-changelog-new-release@3.1.0
with:
tag: ${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}
- name: Update docker image tag version in action.yml
run: |
sed -i "s/image: 'docker:\/\/ghcr.io\/afterlife-guide\/semver.action:.*/image: 'docker:\/\/ghcr.io\/afterlife-guide\/semver.action:${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}'/" action.yml
- name: Commit changelog, manifest and action definition 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 action.yml
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"