Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub workflow for releases #58

Merged
merged 20 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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