-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (151 loc) · 4.9 KB
/
main.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
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
name: CI
on:
push:
tags:
- "v*"
branches:
- master
- next
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
build-binary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.22'
- shell: bash
name: go build
run: |
ci/build-all.sh
env:
BINARY_VERSION: docker-image-build
- name: upload builds
uses: actions/upload-artifact@v2
with:
name: builds
path: builds/
retention-days: 7
determine-image-tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- id: tag
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
export GIT_TAG=${GITHUB_REF#refs/tags/}
else
export GIT_BRANCH=${GITHUB_REF#refs/heads/}
fi
if [[ -n "${GIT_TAG}" ]]; then
echo "::set-output name=tag::${GIT_TAG}"
elif [[ -n "${GIT_BRANCH}" ]]; then
if [[ "${GIT_BRANCH}" == "master" ]]; then
echo "::set-output name=tag::latest"
else
echo "::set-output name=tag::${GIT_BRANCH}"
fi
else
:
fi
build-docker-linux:
needs:
- build-binary
- determine-image-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: builds
path: builds/
- name: docker build
run: |
export ARCH=$([ $(uname -m) = "x86_64" ] && echo "amd64" || echo "arm64")
mkdir -p ~/.docker/cli-plugins/
wget -qO ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.8.2/buildx-v0.8.2.linux-${ARCH}
chmod a+x ~/.docker/cli-plugins/docker-buildx
docker info
docker buildx version
docker buildx ls
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name xbuilder --use
docker buildx inspect --bootstrap
.github/bin/docker-release.sh
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
GHCR_PASSWORD: ${{ secrets.GHCR_PASSWORD }}
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_BUILD_PLATFORM: linux/amd64,linux/arm64,linux/arm/v7,linux/s390x,linux/ppc64le
IMAGE_TAG: ${{needs.determine-image-tag.outputs.tag}}
build-docker-windows:
needs:
- build-binary
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019, windows-2022]
include:
- os: windows-2019
base_tag: "1809"
file: Dockerfile.Windows
- os: windows-2022
base_tag: ltsc2022
file: Dockerfile.Windows
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: builds
path: builds/
- name: docker build
shell: bash
run: |
docker info
docker build --pull -f ${{ matrix.file }} --build-arg BASE_TAG=${{ matrix.base_tag }} -t csi-grpc-proxy-windows:${GITHUB_RUN_ID}-${{ matrix.base_tag }} .
docker inspect csi-grpc-proxy-windows:${GITHUB_RUN_ID}-${{ matrix.base_tag }}
docker save csi-grpc-proxy-windows:${GITHUB_RUN_ID}-${{ matrix.base_tag }} -o csi-grpc-proxy-windows-${{ matrix.base_tag }}.tar
- name: upload image tar
uses: actions/upload-artifact@v2
with:
name: csi-grpc-proxy-windows-${{ matrix.base_tag }}.tar
path: csi-grpc-proxy-windows-${{ matrix.base_tag }}.tar
retention-days: 7
push-docker-windows:
needs:
- build-docker-linux
- build-docker-windows
- determine-image-tag
runs-on:
- self-hosted
- buildah
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: csi-grpc-proxy-windows-1809.tar
- uses: actions/download-artifact@v3
with:
name: csi-grpc-proxy-windows-ltsc2022.tar
- name: push windows images with buildah
run: |
#.github/bin/install_latest_buildah.sh
buildah version
.github/bin/docker-release-windows.sh
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
GHCR_PASSWORD: ${{ secrets.GHCR_PASSWORD }}
DOCKER_CLI_EXPERIMENTAL: enabled
IMAGE_TAG: ${{needs.determine-image-tag.outputs.tag}}