-
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (96 loc) · 3.6 KB
/
go-release.yml
File metadata and controls
106 lines (96 loc) · 3.6 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#
# This file is a part of HyperaDev/actions, licensed under the MIT License.
#
# Copyright (c) 2021-2023 Joshua Sing <joshua@hypera.dev>
# Copyright (c) 2021-2023 LooFifteen <luis@lu15.dev>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# GitHub Actions workflow to release a Go project using GoReleaser.
name: "Release"
on:
workflow_call:
inputs:
go_version:
description: "Go version"
required: false
type: string
default: "stable"
docker_enabled:
description: "Whether to setup Docker and login to container registries"
required: false
type: boolean
default: false
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false
GITHUB_RELEASE_TOKEN:
required: true
jobs:
release:
name: "Release"
runs-on: "ubuntu-latest"
environment:
name: "release"
permissions:
contents: read
packages: write
env:
DOCKER_CLI_EXPERIMENTAL: enabled
steps:
- name: "Checkout repository"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: true
- name: "Fetch tags"
run: git fetch --force --tags
- name: "Setup Go ${{ inputs.go_version }}"
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version: "${{ inputs.go_version }}"
cache: true
check-latest: true
- name: "Setup QEMU"
if: inputs.docker_enabled
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: "Setup Docker Buildx"
if: inputs.docker_enabled
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0
- name: "Login to DockerHub"
if: inputs.docker_enabled
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: "${{ secrets.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_TOKEN }}"
- name: "Login to GitHub Container Registry"
if: inputs.docker_enabled
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: "${{ github.repository_owner }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: "Release"
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # v6.2.1
with:
args: "release --clean"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_RELEASE_TOKEN }}"