-
Notifications
You must be signed in to change notification settings - Fork 26
115 lines (106 loc) · 3.74 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
name: Release
on:
push:
tags:
- 'v*'
env:
IMAGE_NAME: cloud-provider-equinix-metal
GHCR_REGISTRY: ghcr.io/${{ github.repository_owner }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_ORG }}
QUAY_REGISTRY: quay.io/${{ secrets.QUAY_ORG }}
metadata_flavor: latest=true
metadata_tags: type=ref,event=tag
jobs:
images: # create images in docker hub
name: Images
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Set up QEMU for cross-building
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Generate metadata
id: meta
uses: ./.github/actions/metadata
with:
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into DockerHub
uses: docker/login-action@v3
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
if: ${{ env.DOCKER_USERNAME != '' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log into quay.io
uses: docker/login-action@v3
env:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
if: ${{ env.QUAY_USERNAME != '' }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
push: true
build-args: |
BINARY=cloud-provider-equinix-metal
LDFLAGS=-X 'k8s.io/component-base/version.gitVersion=${{ steps.meta.outputs.version }}' -X 'k8s.io/component-base/version/verflag.programName=Cloud Provider Equinix Metal'
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, mode=max, scope=${{ github.workflow }}
release: # create a github actions release with necessary artifacts
name: Release
runs-on: ubuntu-latest
needs:
- images
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate metadata
id: meta
uses: ./.github/actions/metadata
with:
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}
- name: release template
env:
RELEASE_IMG: ${{ env.QUAY_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
run: cat deploy/template/deployment.yaml | sed 's#RELEASE_IMG#${{ env.RELEASE_IMG }}#g' > /tmp/deployment.yaml
- name: Generate Release Notes
run: |
release_notes=$(gh api repos/{owner}/{repo}/releases/generate-notes -F tag_name=${{ github.ref }} --jq .body)
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV
echo "${release_notes}" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
- name: Create Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: /tmp/deployment.yaml
body: ${{ env.RELEASE_NOTES }}
draft: false
prerelease: false