-
-
Notifications
You must be signed in to change notification settings - Fork 109
104 lines (88 loc) · 4.21 KB
/
prepare-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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@v4
with:
fetch-depth: 0
token: ${{ secrets.BUNIT_BOT_TOKEN }}
- name: 🛠️ Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
version: Unreleased
path: ./CHANGELOG.md
- name: ⚙️ Setup GIT versioning
uses: dotnet/[email protected]
id: nbgv
with:
setAllVars: true
- 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@v6
with:
gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BUNIT_BOT_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/[email protected]
with:
setAllVars: true
- name: 🛠️ Increment version.json on main + create release branch
id: versions
run: |
nbgv prepare-release --versionIncrement ${{ github.event.inputs.versionIncrement }}
echo "MAIN_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1 --skip 1)" >> $GITHUB_OUTPUT
git checkout release/v$NBGV_MajorMinorVersion
echo "RELEASE_VERSION_COMMIT_MESSAGE=$(git log --format=%B -n 1)" >> $GITHUB_OUTPUT
# 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/[email protected]
with:
github_token: ${{ secrets.BUNIT_BOT_TOKEN }}
head: release/v${{ steps.nbgv.outputs.MajorMinorVersion }}
base: stable
title: Release of new ${{ github.event.inputs.versionIncrement }} version v${{ steps.nbgv.outputs.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.