-
Notifications
You must be signed in to change notification settings - Fork 6
67 lines (60 loc) · 2.44 KB
/
publish-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
name: GoReleaser Publish Release
on:
workflow_call:
inputs:
isPreRelease:
required: true
type: boolean
secrets:
ghPAT:
required: true
jobs:
publish_release:
name: ${{ inputs.isPreRelease && 'prerelease' || 'release' }} publishing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
-
name: Set variables
id: vars
run: |
if [ -z "${GITHUB_REF_NAME}" ] || [ "${GITHUB_REF_TYPE}" != "tag" ] ; then
echo "Expected a tag push event, skipping release workflow"
exit 1
fi
# Example: tag_name = 0.1.0-rc.4
# echo ${tag_name/-rc.*} = 0.1.0
# echo ${tag_name#*-} = rc.4
tag_name=${GITHUB_REF_NAME}
echo "GORELEASER_CURRENT_TAG=v${tag_name}" >> $GITHUB_ENV
echo "RELEASE_DESCRIPTION=${tag_name}" >> $GITHUB_ENV
RELEASE_NOTES_FILE="docs/release_notes/${tag_name/-rc.*}.md"
echo "RELEASE_NOTES_FILE=${RELEASE_NOTES_FILE}" >> $GITHUB_ENV
if [ ! -f "${RELEASE_NOTES_FILE}" ]; then
echo "Release notes ${RELEASE_NOTES_FILE} not found. Exiting..."
exit 1
fi
echo "RELEASE_BUILD=1" >> $GITHUB_ENV
# Update prerelease version to release-candidate
echo "PRE_RELEASE_ID=${tag_name#*-}" >> $GITHUB_OUTPUT
cat .github/.goreleaser.yml .github/.goreleaser.brew.yml > .github/.goreleaser.combined.yml
-
name: GoReleaser Release
if: ${{ !inputs.isPreRelease }}
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf #v6.1.0
with:
version: v1.26.2
args: release --clean --timeout 60m --skip=validate --config=.github/.goreleaser.combined.yml --release-notes="${{env.RELEASE_NOTES_FILE}}"
env:
GITHUB_TOKEN: ${{ secrets.ghPAT }}
PRE_RELEASE_ID:
-
name: GoReleaser Release Candidate
if: ${{ inputs.isPreRelease }}
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf #v6.1.0
with:
version: v1.26.2
args: release --clean --timeout 60m --skip=validate --config=.github/.goreleaser.yml --release-notes="${{env.RELEASE_NOTES_FILE}}"
env:
GITHUB_TOKEN: ${{ secrets.ghPAT }}
PRE_RELEASE_ID: ${{steps.vars.outputs.PRE_RELEASE_ID}}