Skip to content

Commit

Permalink
Add GitHub workflow for releases (#58)
Browse files Browse the repository at this point in the history
Adds a new GitHub workflow for releases that will:

- Upload the CRDs and default CR manifest
- Build and push the docker image

Closes https://linear.app/prefect/issue/PLA-220/design-release-process

Closes #18
  • Loading branch information
mitchnielsen authored Sep 5, 2024
1 parent b92b4c2 commit afc1c17
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 43 deletions.
28 changes: 28 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# .github/release.yml

changelog:
exclude:
labels:
- maintenance
categories:
- title: Breaking Changes
labels:
- breaking
- title: Dependency Updates
labels:
- dependencies
- title: Documentation
labels:
- docs
- title: Enhancements
labels:
- enhancement
- title: Exciting New Features 🎉
labels:
- feature
- title: Fixes
labels:
- fix
- title: Uncategorized
labels:
- "*"
17 changes: 0 additions & 17 deletions .github/workflows/docker.yaml

This file was deleted.

102 changes: 102 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 }}
26 changes: 0 additions & 26 deletions .github/workflows/tests.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[tools]
actionlint = '1.7.1'
ginkgo = '2.19.0'
golang = '1.21'
golangci-lint = '1.57.2'
kube-controller-tools = '0.14.0'
kubectl = '1.31'
kustomize = '5.3.0'
setup-envtest = '0.17.0'
yamllint = '1.35.1'
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-merge-conflict
- id: check-yaml
args:
- --allow-multiple-documents
- id: detect-private-key
- id: no-commit-to-branch
- id: trailing-whitespace

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
hooks:
- id: yamllint
args:
- --strict

- repo: https://github.com/rhysd/actionlint
rev: v1.7.1
hooks:
- id: actionlint
12 changes: 12 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
extends: default

ignore: |
config/

rules:
comments:
min-spaces-from-content: 1
comments-indentation: disable
document-start: disable
line-length: disable

0 comments on commit afc1c17

Please sign in to comment.