forked from rancher/k3k
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (70 loc) · 2.26 KB
/
gorelease.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Gorelease
on:
push:
pull_request:
workflow_dispatch:
inputs:
commit:
type: string
description: Checkout the specified commit
registry:
type: choice
description: Select the container registry
options:
- dockerhub
- ghcr.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Checkout code at the specific commit
if: "${{ github.event.inputs.commit != '' }}"
run: git checkout ${{ github.event.inputs.commit }}
- name: Set up Go
uses: actions/setup-go@v5
- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
if: "${{ github.event.inputs.registry == 'dockerhub' }}"
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD ;
- name: Login to Docker Container Registry
uses: docker/login-action@v3
if: "${{ github.event.inputs.registry == 'dockerhub' }}"
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
# trigger login also for push
if: "${{ github.event.inputs.registry != 'dockerhub' }}"
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create fake tag
id: fake-tag
run: |
CURRENT_TAG=$(git describe --tag --always)
git tag ${CURRENT_TAG}
echo "CURRENT_TAG=${CURRENT_TAG}" >> "$GITHUB_OUTPUT"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: v2
args: --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.fake-tag.outputs.CURRENT_TAG }}