-
Notifications
You must be signed in to change notification settings - Fork 406
174 lines (146 loc) · 5.67 KB
/
image-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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: release-image-build
on:
workflow_dispatch:
inputs:
commit:
description: 'Commit reference (branch or SHA) from which to build the images.'
required: true
tag:
description: 'Desired release version tag (e.g. v1.0.0-rc.1).'
required: true
jobs:
release_apiserver_image:
env:
working-directory: ./apiserver
name: Release APIServer Docker Image
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: v1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.commit }}
- name: install kubebuilder
run: |
wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.0.0/kubebuilder_$(go env GOOS)_$(go env GOARCH)
sudo mv kubebuilder_$(go env GOOS)_$(go env GOARCH) /usr/local/bin/kubebuilder
- name: Get revision SHA
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Get dependencies
run: go mod download
working-directory: ${{env.working-directory}}
- name: Build
run: go build ./...
working-directory: ${{env.working-directory}}
- name: Test
run: go test ./pkg/... ./cmd/... -race -parallel 4
working-directory: ${{env.working-directory}}
- name: Set up Docker
uses: docker-practice/actions-setup-docker@master
- name: Build Docker Image - Apiserver
run: |
docker build -t kuberay/apiserver:${{ steps.vars.outputs.sha_short }} -f apiserver/Dockerfile .
docker save -o /tmp/apiserver.tar kuberay/apiserver:${{ steps.vars.outputs.sha_short }}
- name: Log in to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Push Apiserver to Quay.io
run: |
docker image tag kuberay/apiserver:${{ steps.vars.outputs.sha_short }} quay.io/kuberay/apiserver:${{ steps.vars.outputs.sha_short }};
docker push quay.io/kuberay/apiserver:${{ steps.vars.outputs.sha_short }};
docker image tag kuberay/apiserver:${{ steps.vars.outputs.sha_short }} quay.io/kuberay/apiserver:${{ github.event.inputs.tag }};
docker push quay.io/kuberay/apiserver:${{ github.event.inputs.tag }}
release_operator_image:
env:
working-directory: ./ray-operator
name: Release Operator Docker Images
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: v1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.commit }}
- name: install kubebuilder
run: |
wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.0.0/kubebuilder_$(go env GOOS)_$(go env GOARCH)
sudo mv kubebuilder_$(go env GOOS)_$(go env GOARCH) /usr/local/bin/kubebuilder
- name: Get revision SHA
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Get dependencies
run: go mod download
working-directory: ${{env.working-directory}}
- name: Build
run: make build
working-directory: ${{env.working-directory}}
- name: Test
run: make test
working-directory: ${{env.working-directory}}
- name: Set up Docker
uses: docker-practice/actions-setup-docker@master
- name: Build Docker Image - Operator
run: |
IMG=kuberay/operator:${{ steps.vars.outputs.sha_short }} make docker-image
working-directory: ${{env.working-directory}}
- name: Log in to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
# Build operators inside the gh runner vm directly and then copy the go binaries to docker images using the Dockerfile.buildx
- name: Build linux/amd64 Operator go binary
env:
CGO_ENABLED: 1
GOOS: linux
GOARCH: amd64
run: |
CGO_ENABLED=$CGO_ENABLED GOOS=$GOOS GOARCH=$GOARCH go build -tags strictfipsruntime -a -o manager-$GOARCH main.go
working-directory: ${{env.working-directory}}
- name: Build linux/arm64 Operator binary
env:
CC: aarch64-linux-gnu-gcc
CGO_ENABLED: 1
GOOS: linux
GOARCH: arm64
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross
CC=$CC CGO_ENABLED=$CGO_ENABLED GOOS=$GOOS GOARCH=$GOARCH go build -tags strictfipsruntime -a -o manager-$GOARCH main.go
working-directory: ${{env.working-directory}}
- name: Build MultiArch Image
uses: docker/build-push-action@v5
env:
PUSH: true
REPO_ORG: kuberay
REPO_NAME: operator
with:
platforms: linux/amd64,linux/arm64
context: ${{env.working-directory}}
file: ${{env.working-directory}}/Dockerfile.buildx
push: ${{env.PUSH}}
provenance: false
tags: |
quay.io/${{env.REPO_ORG}}/${{env.REPO_NAME}}:${{ steps.vars.outputs.sha_short }}
quay.io/${{env.REPO_ORG}}/${{env.REPO_NAME}}:${{ github.event.inputs.tag }}
- name: Create tag
uses: actions/github-script@v6
with:
script: |
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/ray-operator/${{ github.event.inputs.tag }}',
sha: '${{ github.event.inputs.commit }}'
})