Skip to content

Commit fbbcb72

Browse files
authored
Merge pull request #923 from timofurrer/workflow/release-notes
Automatically add changelog as release notes to GitHub release
2 parents d99380e + f0f191f commit fbbcb72

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# This GitHub action can publish assets for release when a tag is created.
22
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
33
#
4-
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
4+
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
55
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
66
# secret. If you would rather own your own GPG handling, please fork this action
77
# or use an alternative one for key handling.
88
#
9-
# You will need to pass the `--batch` flag to `gpg` in your signing step
9+
# You will need to pass the `--batch` flag to `gpg` in your signing step
1010
# in `goreleaser` to indicate this is being used in a non-interactive mode.
1111
#
1212
name: release
@@ -28,31 +28,32 @@ jobs:
2828
runs-on: ubuntu-latest
2929
needs: [go-version]
3030
steps:
31-
-
32-
name: Checkout
31+
- name: Checkout
3332
uses: actions/checkout@v3
34-
-
35-
name: Unshallow
33+
- name: Unshallow
3634
run: git fetch --prune --unshallow
37-
-
38-
name: Set up Go
35+
- name: Set up Go
3936
uses: actions/setup-go@v2
4037
with:
4138
go-version: ${{ needs.go-version.outputs.go-version }}
42-
-
43-
name: Import GPG key
39+
- name: Import GPG key
4440
id: import_gpg
4541
uses: hashicorp/[email protected]
4642
env:
4743
# These secrets will need to be configured for the repository:
4844
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
4945
PASSPHRASE: ${{ secrets.PASSPHRASE }}
50-
-
51-
name: Run GoReleaser
46+
- name: Generate Release Notes from Changelog
47+
run: |
48+
LATEST_TAG=$(git describe --abbrev=0 --match='v*.*.*' --tags | tr -d v)
49+
PREVIOUS_TAG=$(git describe --abbrev=0 --exclude="$(git describe --abbrev=0 --match='v*.*.*' --tags)" --match='v*.*.*' --tags | tr -d v)
50+
sed -n "/## $LATEST_TAG/,/## $PREVIOUS_TAG"'/{//!p;}' CHANGELOG.md > /tmp/RELEASE-NOTES.md
51+
cat /tmp/RELEASE-NOTES.md
52+
- name: Run GoReleaser
5253
uses: goreleaser/[email protected]
5354
with:
5455
version: latest
55-
args: release --rm-dist
56+
args: release --release-notes /tmp/RELEASE-NOTES.md --rm-dist
5657
env:
5758
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
5859
# GitHub sets this automatically

.goreleaser.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ checksum:
3737
signs:
3838
- artifacts: checksum
3939
args:
40-
# if you are using this in a GitHub action or some other automated pipeline, you
40+
# if you are using this in a GitHub action or some other automated pipeline, you
4141
# need to pass the batch flag to indicate its not interactive.
4242
- "--batch"
4343
- "--local-user"
@@ -50,7 +50,3 @@ release:
5050
extra_files:
5151
- glob: 'terraform-registry-manifest.json'
5252
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
53-
# If you want to manually examine the release before its live, uncomment this line:
54-
# draft: true
55-
changelog:
56-
skip: true

0 commit comments

Comments
 (0)