-
Notifications
You must be signed in to change notification settings - Fork 41
143 lines (123 loc) · 3.96 KB
/
release.yaml
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# workflow to release assets as part of the release
name: Upload Release Asset
on:
push:
tags:
- "v*"
env:
REGISTRY: ghcr.io/${{ github.repository }}
GO_VERSION: "1.20"
permissions:
packages: write
contents: write
jobs:
image:
name: Build and push ${{ matrix.target }} image
runs-on: ubuntu-latest
strategy:
matrix:
target: [bootstrap, controlplane]
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.target }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.target }}-
${{ runner.os }}-buildx-
- name: Docker ${{ matrix.target }} metadata
id: meta
uses: docker/metadata-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: ${{ env.REGISTRY }}/${{ matrix.target }}-controller
flavor: latest=false
tags: type=ref,event=tag
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Env
run: |
DOCKER_BUILD_LDFLAGS="$(hack/version.sh)"
echo 'DOCKER_BUILD_LDFLAGS<<EOF' >> $GITHUB_ENV
echo $DOCKER_BUILD_LDFLAGS >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Build and push ${{ matrix.target }} image
uses: docker/build-push-action@v4
with:
context: .
push: true
build-args: |
LDFLAGS=${{ env.DOCKER_BUILD_LDFLAGS }}
package=./${{ matrix.target }}/main.go
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
release:
name: Release
runs-on: ubuntu-latest
needs:
- image
steps:
- uses: actions/checkout@v3
- name: Set release
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- uses: actions/cache@v3
with:
path: hack/tools/bin
key: ${{ runner.os }}-tools-bin-release-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-tools-bin-release-
${{ runner.os }}-tools-bin-
- name: Docker ${{ matrix.target }} metadata
id: meta
uses: docker/metadata-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
${{ env.REGISTRY }}/controlplane-controller
${{ env.REGISTRY }}/bootstrap-controller
flavor: latest=false
tags: type=ref,event=tag
- name: manifest
run: |
make release
- name: manifest
run: make release-notes
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: out/*
body_path: _releasenotes/${{ env.RELEASE_TAG }}.md
draft: true
prerelease: false