Skip to content

Commit 5f0cda1

Browse files
authored
Another attempt at fixing release notes (#4649)
## Changes Apparently environment variables cannot be interpolated into the arguments of another Github action. This is the last attempt which should work by writing the release notes into a well-known file outside of the current directory (in `/tmp`). ## Tests NO_CHANGELOG=true
1 parent be82cb1 commit 5f0cda1

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,40 @@ jobs:
3838
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
3939
PASSPHRASE: ${{ secrets.PASSPHRASE }}
4040

41-
- name: Set GoReleaser args
41+
- name: Write release notes to file
4242
run: |
4343
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
44-
RELEASE_NOTES_DIR=$(mktemp -d)
44+
RELEASE_NOTES_DIR=/tmp/release-notes
45+
mkdir -p "$RELEASE_NOTES_DIR"
4546
RELEASE_NOTES_FILE="$RELEASE_NOTES_DIR/release-notes.md"
4647
git for-each-ref --format='%(body)' ${{ github.ref }} > "$RELEASE_NOTES_FILE"
48+
echo "Release notes file: $RELEASE_NOTES_FILE"
4749
echo "Release notes contents:"
4850
cat "$RELEASE_NOTES_FILE"
49-
GORELEASER_ARGS="--release-notes $RELEASE_NOTES_FILE"
50-
echo "GORELEASER_ARGS=$GORELEASER_ARGS" >> $GITHUB_ENV
5151
else
5252
echo "Not a release tag, skipping release notes"
53-
GORELEASER_ARGS="--snapshot"
54-
echo "GORELEASER_ARGS=$GORELEASER_ARGS" >> $GITHUB_ENV
5553
fi
5654
5755
- name: Run GoReleaser
5856
uses: goreleaser/goreleaser-action@v6
57+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
5958
with:
6059
version: ~> v2
61-
args: release --clean $GORELEASER_ARGS
60+
# Arguments cannot reference environment variables, so we write the release notes
61+
# to a well-known location and use that in the goreleaser command.
62+
args: release --clean --release-notes=/tmp/release-notes/release-notes.md
63+
env:
64+
# use GITHUB_TOKEN that is already available in secrets.GITHUB_TOKEN
65+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
68+
69+
- name: Run GoReleaser (snapshot)
70+
uses: goreleaser/goreleaser-action@v6
71+
if: ${{ ! startsWith(github.ref , 'refs/tags/v') }}
72+
with:
73+
version: ~> v2
74+
args: release --clean --snapshot
6275
env:
6376
# use GITHUB_TOKEN that is already available in secrets.GITHUB_TOKEN
6477
# https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token

0 commit comments

Comments
 (0)