prepare-release #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: prepare-release | |
concurrency: 'prepare-release' | |
on: | |
workflow_dispatch: | |
inputs: | |
versionIncrement: | |
description: 'The version increment. Allowed values are "major" and "minor".' | |
required: true | |
default: 'minor' | |
jobs: | |
prepare-release: | |
name: 🚚 Prepare new release | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && contains(fromJson('["major","minor"]'), github.event.inputs.versionIncrement) | |
steps: | |
- name: 🛒 Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.ATCBOT_TOKEN }} | |
- name: 🛠️ Get Changelog Entry | |
id: changelog_reader | |
uses: mindsers/changelog-reader-action@v2 | |
with: | |
version: Unreleased | |
path: ./CHANGELOG.md | |
- name: ☑ Check that release contains changes | |
if: steps.changelog_reader.outputs.changes == '' | |
run: | | |
echo "::error file=CHANGELOG.md::The unreleased section in the changelog is empty. Nothing to release." | |
exit 1 | |
- name: ⚙️ Import GPG key | |
id: import_gpg | |
uses: crazy-max/ghaction-import-gpg@v3 | |
with: | |
gpg-private-key: ${{ secrets.ATCBOT_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.ATCBOT_GPG_KEY_PASSPHRASE }} | |
- name: ⚙️ Setup CI GIT | |
run: | | |
git config user.name "${{ steps.import_gpg.outputs.name }}" | |
git config user.email ${{ steps.import_gpg.outputs.email }} | |
git config --global user.signingkey ${{ steps.import_gpg.outputs.keyid }} | |
git config --global commit.gpgsign true | |
- name: ⚙️ Setup GIT versioning | |
uses: dotnet/nbgv@v0.4.0 | |
with: | |
setAllVars: true | |
- name: 🛠️ Increment version.json on main + create release branch | |
id: versions | |
run: | | |
nbgv prepare-release --versionIncrement ${{ github.event.inputs.versionIncrement }} | |
echo "::set-output name=MAIN_VERSION_COMMIT_MESSAGE::$(git log --format=%B -n 1 --skip 1)" | |
git checkout release/v$NBGV_MajorMinorVersion | |
echo "::set-output name=RELEASE_VERSION_COMMIT_MESSAGE::$(git log --format=%B -n 1)" | |
# Workaround since nbgv prepare-release does not sign commits. | |
# This undo's the commits, keeps the version changes, and commits again with signing | |
# with the saved commit messages from previous step. | |
# See: https://github.com/dotnet/Nerdbank.GitVersioning/issues/594 | |
- name: 🛠️ Sign commits on main and release branch | |
run: | | |
git checkout release/v$NBGV_MajorMinorVersion | |
git reset --soft HEAD~1 | |
git commit -S -m "${{ steps.versions.outputs.RELEASE_VERSION_COMMIT_MESSAGE }}" | |
git checkout main | |
git reset --hard HEAD~1 | |
git reset --soft HEAD~1 | |
git commit -S -m "${{ steps.versions.outputs.MAIN_VERSION_COMMIT_MESSAGE }}" | |
git merge -S -X ours release/v$NBGV_MajorMinorVersion | |
- name: ⏩ Push version.json updates to main | |
run: git push origin main | |
- name: ⏩ Push release branch to origin | |
run: git push origin release/v$NBGV_MajorMinorVersion | |
- name: ⏭ Create pull request for release branch | |
uses: thomaseizinger/create-pull-request@1.0.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.ATCBOT_TOKEN }} | |
with: | |
head: release/v${{ env.NBGV_MajorMinorVersion }} | |
base: stable | |
title: Release of new ${{ github.event.inputs.versionIncrement }} version v${{ env.NBGV_MajorMinorVersion }} | |
body: | | |
This PR was created in response to a manual trigger of the [prepare-release workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). | |
Merging this PR will create a GitHub Release and push new packages to NuGet. | |
**NOTE:** Only small fixes should be added to this PR at this point. If you need to make minor or major changes, close the PR and make those changes to ${{ github.ref }} instead, and run the prepare-release workflow again once you are done. |