-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (87 loc) · 2.98 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
# Prefect Operator release workflow.
name: Release
"on":
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
permissions: {}
jobs:
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install tool dependencies
uses: jdx/mise-action@v2
- name: Build
run: make build
- name: Test
run: make test
build-and-upload-manifests:
needs: unit-tests
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install tool dependencies
uses: jdx/mise-action@v2
- name: Build manifests
run: |
(cd config/manager && kustomize edit set image controller=prefecthq/prefect-operator:${{ github.ref_name }})
kustomize build config/crd > prefect-crds.yaml
kustomize build config/default > prefect.yaml
- name: Upload release assets
if: github.ref_type == 'tag'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref_name }} prefect-crds.yaml prefect.yaml
build-and-push-docker-image:
needs: unit-tests
runs-on: ubuntu-latest
# The GitHub environments are created by Terraform and map to Docker Hub repositories:
# - dev: https://hub.docker.com/r/prefecthq/prefect-operator-dev
# - prod: https://hub.docker.com/r/prefecthq/prefect-operator
# The environment will be 'prod' if the GitHub event is a release. Otherwise, it will be 'dev'.
environment: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
# These credentials are managed in Terraform. Depending on the 'environment' value above,
# these will either be the credentials for 'dev' or 'prod'.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker image metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: prefecthq/prefect-operator${{ github.event_name == 'pull_request' && '-dev' }}
tags: |
type=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}}
labels: |
org.opencontainers.image.title=prefect-operator
org.opencontainers.image.description=Prefect Operator image
org.opencontainers.image.vendor=Prefect
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}