-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (61 loc) · 1.87 KB
/
release.yaml
File metadata and controls
66 lines (61 loc) · 1.87 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
name: goreleaser
on:
push:
# run only against tags
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: Existing fork tag to release, for example v6.9.36-0
required: false
type: string
permissions:
contents: write
concurrency:
group: goreleaser-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.tag || github.ref }}
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: '>=1.26.0'
cache: true
- name: Generate Build Metadata
run: |
VERSION="${{ inputs.tag }}"
if [ -z "$VERSION" ]; then
VERSION="${GITHUB_REF_NAME}"
fi
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
echo "BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_ENV"
- name: Check existing release
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view "${VERSION}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "[i] ${VERSION} release already exists; skipping GoReleaser."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- uses: goreleaser/goreleaser-action@v4
if: steps.release.outputs.exists != 'true'
with:
distribution: goreleaser
version: latest
args: release --clean --skip=validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ env.VERSION }}
COMMIT: ${{ env.COMMIT }}
BUILD_DATE: ${{ env.BUILD_DATE }}