-
Notifications
You must be signed in to change notification settings - Fork 27
157 lines (152 loc) · 6.18 KB
/
release.yaml
File metadata and controls
157 lines (152 loc) · 6.18 KB
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
name: release
run-name: "${{ github.event.inputs.kubesolo_version }} release 🚀"
on:
workflow_dispatch:
inputs:
kubesolo_version:
description: "kubesolo version. e.g. v0.x.x, v0.x.x-beta"
required: true
permissions:
contents: write
jobs:
release:
name: create a pre-release
runs-on: ubuntu-latest
steps:
- name: "[execution] create a pre-release"
run: |
gh release create \
"${{ github.event.inputs.kubesolo_version }}" \
--repo portainer/kubesolo \
--title "${{ github.event.inputs.kubesolo_version }}" \
--target develop \
--prerelease \
--generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: release for kubesolo-linux-${{ matrix.goarch }}${{ matrix.libc == 'musl' && '-musl' || '' }}${{ matrix.variant == 'offline' && '-offline' || '' }}
runs-on: ubuntu-latest
needs: [release]
strategy:
matrix:
goarch: [amd64, arm64, arm, riscv64]
libc: [glibc, musl]
variant: [online, offline]
steps:
- name: "[preparation] checkout the current branch"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
tags: true
- name: "[preparation] set build time"
run: echo BUILD_TIME=$(date) >> ${GITHUB_ENV}
- name: "[preparation] set up QEMU for cross-platform Docker builds"
if: matrix.goarch == 'arm'
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: arm
- name: "[preparation] set up golang"
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: "[preparation] release-workflow-deps"
run: sudo make release-workflow-deps
- name: "[preparation] resolve build target"
id: target
run: |
TARGET="build"
if [[ "${{ matrix.libc }}" == "musl" ]]; then TARGET="build-musl"; fi
if [[ "${{ matrix.variant }}" == "offline" ]]; then TARGET="${TARGET}-offline"; fi
echo "build_target=${TARGET}" >> "$GITHUB_OUTPUT"
- name: "[execution] build the binary for linux/${{ matrix.goarch }}"
run: make ${{ steps.target.outputs.build_target }} GOOS=linux GOARCH=${{ matrix.goarch }} VERSION="${{ github.event.inputs.kubesolo_version }}" OUTPUT=kubesolo
- name: "[post] upload artifacts to github release"
run: |
dist=kubesolo-${{ github.event.inputs.kubesolo_version }}-linux-${{ matrix.goarch }}${{ matrix.libc == 'musl' && '-musl' || '' }}${{ matrix.variant == 'offline' && '-offline' || '' }}
tar -czf "$dist.tar.gz" kubesolo
gh release upload --clobber --repo portainer/kubesolo "${{ github.event.inputs.kubesolo_version }}" "$dist.tar.gz"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker-build:
name: docker image for linux/${{ matrix.goarch }}
runs-on: ubuntu-latest
needs: [release]
permissions:
contents: read
env:
REGISTRY: docker.io
IMAGE_NAME: portainer/kubesolo
strategy:
matrix:
goarch: [amd64, arm64, arm, riscv64]
steps:
- name: "[preparation] checkout the current branch"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
tags: true
- name: "[preparation] set up QEMU for cross-platform Docker builds"
if: matrix.goarch != 'amd64'
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: linux/${{ matrix.goarch }}
- name: "[preparation] set up golang"
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: "[preparation] release-workflow-deps"
run: sudo make release-workflow-deps
- name: "[execution] build linux/${{ matrix.goarch }} musl binary"
run: make build-musl GOOS=linux GOARCH=${{ matrix.goarch }} VERSION="${{ github.event.inputs.kubesolo_version }}"
- name: "[preparation] set up docker buildx"
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: "[preparation] log in to docker hub"
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: "[execution] build and push linux/${{ matrix.goarch }} image"
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: .
platforms: linux/${{ matrix.goarch }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.kubesolo_version }}-linux-${{ matrix.goarch }}
cache-from: type=gha
cache-to: type=gha,mode=max
docker-manifest:
name: create multi-arch docker manifest
runs-on: ubuntu-latest
needs: [docker-build]
permissions:
contents: read
env:
REGISTRY: docker.io
IMAGE_NAME: portainer/kubesolo
steps:
- name: "[preparation] log in to docker hub"
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: "[execution] create and push multi-arch manifest"
run: |
VERSION="${{ github.event.inputs.kubesolo_version }}"
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
docker manifest create ${IMAGE}:${VERSION} \
${IMAGE}:${VERSION}-linux-amd64 \
${IMAGE}:${VERSION}-linux-arm64 \
${IMAGE}:${VERSION}-linux-arm \
${IMAGE}:${VERSION}-linux-riscv64
docker manifest push ${IMAGE}:${VERSION}
docker manifest create ${IMAGE}:latest \
${IMAGE}:${VERSION}-linux-amd64 \
${IMAGE}:${VERSION}-linux-arm64 \
${IMAGE}:${VERSION}-linux-arm \
${IMAGE}:${VERSION}-linux-riscv64
docker manifest push ${IMAGE}:latest