-
Notifications
You must be signed in to change notification settings - Fork 71
118 lines (105 loc) · 3.57 KB
/
create-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
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
107
108
109
110
111
112
113
114
115
116
117
118
name: Create release
on:
pull_request:
branches:
- master
- release-**-**
types: [ closed ]
permissions:
contents: write
packages: write
actions: read
pull-requests: read
env:
REGISTRY: ghcr.io
# Common versions
GO_VERSION: '1.22'
jobs:
check-tag:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'update manifest and helm charts')
runs-on: ubuntu-latest
outputs:
release-tag: ${{ steps.set-tags.outputs.release-tag }}
init-tag: ${{ steps.set-tags.outputs.init-tag }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- id: set-tags
name: set-tags
run: |
echo "release-tag=$(echo ${{ github.event.pull_request.head.ref }} | tr '-' '\n' | grep 'v[0-9]\.[0-9]\.[0-9]' | head -n 1)" >> $GITHUB_OUTPUT
echo "init-tag=$(echo ${{ github.event.pull_request.head.ref }} | tr '-' '\n' | grep -E '^[0-9]\.[0-9]\.[0-9]$' | head -n 1)" >> $GITHUB_OUTPUT
- id: check-tag
name: Check for Tag
run: |
if git show-ref --tags --verify --quiet "refs/tags/${{ steps.set-tags.outputs.release-tag }}"; then
echo "create_tag=$(echo 'false' )" >> $GITHUB_OUTPUT
else
echo "create_tag=$(echo 'true' )" >> $GITHUB_OUTPUT
fi
- name: 'Create tag'
if: steps.check-tag.outputs.create_tag == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.set-tags.outputs.release-tag }}',
sha: context.sha
})
create-release:
runs-on: ubuntu-latest
needs:
- check-tag
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
ref: ${{ needs.check-tag.outputs.release-tag }}
- name: Goreleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean --timeout 60m --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ needs.check-tag.outputs.release-tag }}
export-registry:
runs-on: ubuntu-latest
outputs:
registry: ${{ steps.export.outputs.registry }}
steps:
- id: export
run: |
# registry must be in lowercase
echo "::set-output name=registry::$(echo "${{ env.REGISTRY }}/${{ github.repository }}" | tr [:upper:] [:lower:])"
publish-image:
needs:
- check-tag
- export-registry
uses: ./.github/workflows/publish-image.yml
with:
registry: ${{ needs.export-registry.outputs.registry }}
release_version: ${{ needs.check-tag.outputs.release-tag }}
publish-init-validation-image:
needs:
- check-tag
- export-registry
uses: ./.github/workflows/publish-init-container-image.yml
with:
registry: ${{ needs.export-registry.outputs.registry }}
release_version: ${{ needs.check-tag.outputs.release-tag }}
init_container_version: ${{ needs.check-tag.outputs.init-tag }}