-
Notifications
You must be signed in to change notification settings - Fork 48
122 lines (108 loc) · 4.35 KB
/
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
119
120
121
122
name: Release
on:
push:
tags:
- v* # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
release:
name: release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
tag_name: ${{ steps.branch_name.outputs.TAG_NAME }}
image_tag: ${{ steps.image_tag.outputs.IMAGE_TAGS }}
steps:
# Ugly hack to get the tag name
# github.ref gives the full reference like refs.tags.v0.0.1-beta1
- name: Branch name
id: branch_name
run: |
echo TAG_NAME="${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: shogo82148/[email protected]
with:
release_name: ${{ steps.branch_name.outputs.TAG_NAME }}
draft: true # So we can manually edit before publishing
prerelease: ${{ contains(github.ref, '-') }}
- name: Prepare image tags
id: image_tag
env:
TAGS: ${{ steps.branch_name.outputs.TAG_NAME }}
# Basically just replace the '+' with '-' as '+' is not allowed in tags
run: |
echo IMAGE_TAGS="${TAGS//+/-}" >> $GITHUB_OUTPUT
build-image:
needs:
- release
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Run git checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.6'
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Quay registry
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build image and push to Docker Hub and GitHub image registry
uses: docker/build-push-action@v6
with:
build-args: |
BUILD_IMG=golang:1.22.6
context: .
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/k0sproject/k0smotron:${{ needs.release.outputs.image_tag }}
quay.io/k0sproject/k0smotron:${{ needs.release.outputs.image_tag }}
push: true
- name: Create install files
if: github.repository == 'k0sproject/k0smotron'
run: |
make bootstrap-components.yaml IMG=quay.io/k0sproject/k0smotron:${{ needs.release.outputs.image_tag }}
make control-plane-components.yaml IMG=quay.io/k0sproject/k0smotron:${{ needs.release.outputs.image_tag }}
make infrastructure-components.yaml IMG=quay.io/k0sproject/k0smotron:${{ needs.release.outputs.image_tag }}
- name: Upload Release Assets - metadata.yaml
id: upload-release-asset-metadata
uses: shogo82148/[email protected]
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./metadata.yaml
asset_name: metadata.yaml
asset_content_type: application/octet-stream
- name: Upload Release Assets - bootstrap-components.yaml
id: upload-release-asset-bootstrap
uses: shogo82148/[email protected]
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./bootstrap-components.yaml
asset_name: bootstrap-components.yaml
asset_content_type: application/octet-stream
- name: Upload Release Assets - control-plane-components.yaml
id: upload-release-asset-control-plane
uses: shogo82148/[email protected]
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./control-plane-components.yaml
asset_name: control-plane-components.yaml
asset_content_type: application/octet-stream
- name: Upload Release Assets - infrastructure-components.yaml
id: upload-release-asset-images
uses: shogo82148/[email protected]
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./infrastructure-components.yaml
asset_name: infrastructure-components.yaml
asset_content_type: application/octet-stream