Skip to content

Draft new production release #19

Draft new production release

Draft new production release #19

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
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
draft-new-release:
name: "Draft a new release"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
token: ${{ secrets.CREATE_PR_TOKEN }}
fetch-depth: 0
- name: Create release branch
env:
MAJOR_VERSION: ${{ github.event.inputs.major_version }}
MINOR_VERSION: ${{ github.event.inputs.minor_version }}
PATCH_VERSION: ${{ github.event.inputs.patch_version }}
RUN_NUMBER: ${{ github.run_number }}
run: git checkout -b release/$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.$RUN_NUMBER
- name: Update Version Number
uses: Afterlife-Guide/SemVer.Action@dbf2fca7a9c13acae677a3a7924aa5b18cab1543
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: baynezy/ChangeLogger.Action@e9ba913995eaeeb49b0f9e21abcb2e98937ffb9c
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
env:
MAJOR_VERSION: ${{ github.event.inputs.major_version }}
MINOR_VERSION: ${{ github.event.inputs.minor_version }}
PATCH_VERSION: ${{ github.event.inputs.patch_version }}
RUN_NUMBER: ${{ github.run_number }}
run: |
sed -i "s/image: 'docker:\/\/ghcr.io\/afterlife-guide\/semver.action:.*/image: 'docker:\/\/ghcr.io\/afterlife-guide\/semver.action:$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.$RUN_NUMBER'/" action.yml
- name: Commit changelog, manifest and action definition files
id: make-commit
env:
MAJOR_VERSION: ${{ github.event.inputs.major_version }}
MINOR_VERSION: ${{ github.event.inputs.minor_version }}
PATCH_VERSION: ${{ github.event.inputs.patch_version }}
RUN_NUMBER: ${{ github.run_number }}
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 $MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.$RUN_NUMBER"
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Push new branch
env:
MAJOR_VERSION: ${{ github.event.inputs.major_version }}
MINOR_VERSION: ${{ github.event.inputs.minor_version }}
PATCH_VERSION: ${{ github.event.inputs.patch_version }}
RUN_NUMBER: ${{ github.run_number }}
run: git push origin release/$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.$RUN_NUMBER
- name: Create pull request
env:
GH_TOKEN: ${{ secrets.CREATE_PR_TOKEN }}
ACTOR: ${{ github.actor }}
REPOSITORY: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
COMMIT_SHA: ${{ steps.make-commit.outputs.commit }}
MAJOR_VERSION: ${{ github.event.inputs.major_version }}
MINOR_VERSION: ${{ github.event.inputs.minor_version }}
PATCH_VERSION: ${{ github.event.inputs.patch_version }}
RUN_NUMBER: ${{ github.run_number }}
run: |
echo -e "Hi @$ACTOR!\n\nThis PR was created in response to a manual trigger of the release workflow here: https://github.com/$REPOSITORY/actions/runs/$RUN_ID.\nI've updated the changelog and bumped the versions in the manifest files in this commit: $COMMIT_SHA.\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/$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.$RUN_NUMBER \
--base master \
--title "Release version $MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION.$RUN_NUMBER" \
--reviewer $ACTOR \
--body "$msg"