Repository navigation
126 lines (113 loc) · 4.25 KB
/
Copy pathrelease.yaml
File metadata and controls
126 lines (113 loc) · 4.25 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
name: Release Operator
on:
pull_request:
branches: [v1.*]
push:
tags: [v1.*]
workflow_dispatch:
inputs:
tag:
description: "Existing tag to build and publish, e.g. v1.0.9-17"
required: true
type: string
env:
# Consumed by the Makefile to derive the image VERSION. A tag push publishes
# the tag that triggered it; a manual run publishes the tag it was given.
SEMREV_LABEL: ${{ inputs.tag || github.ref_name }}
permissions:
contents: read
jobs:
# Build each architecture natively and push it under its own tag. Native
# builders are used in preference to QEMU because the operator binary is
# built with CGO_ENABLED=1, which is prohibitively slow under emulation.
build-and-push-image:
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runs-on: ubuntu-latest
- arch: arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.runs-on }}
permissions:
contents: read
packages: write
steps:
# Guard against a typo becoming a published image tag. A tag that does
# not exist is caught by the checkout below.
- name: Check the requested tag
if: github.event_name == 'workflow_dispatch'
env:
TAG: ${{ inputs.tag }}
run: |
case "${TAG}" in
v1.*) echo "publishing ${TAG}" ;;
*) echo "::error::tag must match v1.* (got '${TAG}')"; exit 1 ;;
esac
# Empty ref means the ref for the triggering event, so tag pushes and pull
# requests are unaffected; a manual run builds the tag it was given, not
# the branch the workflow was dispatched from.
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.tag }}
- name: Build
run: |
scripts/install-tools.sh
make image ARCH=${{ matrix.arch }}
- name: Log in to the GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push
if: github.event_name != 'pull_request'
run: make image-push ARCH=${{ matrix.arch }}
# Combine the per-architecture images pushed above into a manifest list. This
# runs as a separate job so that every architecture is already tagged in the
# registry before the list references it.
manifest:
needs: build-and-push-image
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Deliberately not the tag being published: this needs the
# image-push-manifest target, which older tags predate. Only the image
# names matter here and those come from SEMREV_LABEL, not the source.
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Log in to the GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- name: Push manifest list
run: make image-push-manifest
create-release:
name: Create GitHub Release
needs: [manifest]
# Only for a tag push. A manual run republishes images for a tag that has
# already been released, and must not rewrite its release notes.
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Release Operator Version
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
allowUpdates: "true"
bodyFile: release_notes/${{ env.SEMREV_LABEL }}.md
tag: ${{ env.SEMREV_LABEL }}
token: ${{ secrets.GITHUB_TOKEN }}