-
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (70 loc) · 2.17 KB
/
Copy pathrelease.yml
File metadata and controls
79 lines (70 loc) · 2.17 KB
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
name: Release
on:
workflow_dispatch:
inputs:
snapshot:
description: "Build a snapshot instead of publishing a release"
required: false
default: "false"
type: boolean
version:
description: "Version to publish (must match VERSION file)"
required: false
default: ""
type: string
permissions:
contents: write
jobs:
release:
name: GoReleaser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Load version
shell: bash
run: echo "VERSION=$(tr -d '\r\n' < VERSION)" >> "$GITHUB_ENV"
- name: Verify version override
if: inputs.version != ''
shell: bash
run: |
if [ "${{ inputs.version }}" != "$VERSION" ]; then
echo "::error::Input version ${{ inputs.version }} does not match VERSION file ($VERSION)" >&2
exit 1
fi
- name: Create release tag
if: inputs.snapshot == false
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
TAG="v${VERSION}"
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
echo "::warning::Tag ${TAG} already exists, skipping tag creation."
else
git tag -a "${TAG}" -m "Release ${TAG}"
git push origin "${TAG}"
fi
- name: Run GoReleaser (snapshot)
if: inputs.snapshot == true
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --snapshot --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser (release)
if: inputs.snapshot == false
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}