Skip to content

Commit

Permalink
add CI from main to build new kwasm-lifefycle-manager images (#70)
Browse files Browse the repository at this point in the history
* add ci from main

* adjust ci to build for dev branch

* fix linting issues
  • Loading branch information
voigt authored Jan 28, 2024
1 parent 4c2230b commit 63ef857
Show file tree
Hide file tree
Showing 12 changed files with 549 additions and 21 deletions.
17 changes: 10 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
versioning-strategy: "lockfile-only"
allowed_updates:
- match:
dependency_type: "all"
update_type: "semver:patch"
66 changes: 66 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
categories:
- title: '⚠️ Breaking changes'
labels:
- 'kind/major'
- 'kind/breaking-change'
- title: '🚀 Features'
labels:
- 'kind/enhancement'
- 'kind/feature'
- title: '🐛 Bug Fixes'
labels:
- 'kind/bug'
- title: '🧰 Maintenance'
labels:
- 'kind/chore'
- 'area/dependencies'

exclude-labels:
- duplicate
- invalid
- later
- wontfix
- kind/question
- release/skip-changelog

change-template: '- $TITLE (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
name-template: 'v$RESOLVED_VERSION'
template: |
$CHANGES
autolabeler:
# Tag any PR with "!" in the subject as major update. In other words, breaking change
- label: 'kind/breaking-change'
title: '/.*!:.*/'
- label: 'area/dependencies'
title: 'chore(deps)'
- label: 'area/dependencies'
title: 'fix(deps)'
- label: 'area/dependencies'
title: 'build(deps)'
- label: 'kind/feature'
title: 'feat'
- label: 'kind/bug'
title: 'fix'
- label: 'kind/chore'
title: 'chore'

version-resolver:
major:
labels:
- 'kind/major'
- 'kind/breaking-change'
minor:
labels:
- 'kind/minor'
- 'kind/feature'
- 'kind/enhancement'
patch:
labels:
- 'kind/patch'
- 'kind/fix'
- 'kind/bug'
- 'kind/chore'
- 'area/dependencies'
default: patch
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
workflow_call:
push:
pull_request:

# Declare default permissions as read only.
permissions: read-all

jobs:
unit_tests:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: "1.21"
- run: make test

golangci:
name: Golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: "1.21"
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.54.2
38 changes: 38 additions & 0 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build container image, sign it, and generate SBOMs

on:
workflow_call:
outputs:
digest:
description: "Container image digest"
value: ${{jobs.build.outputs.digest}}

push:
branches:
- "kwasm-lifecycle-manager"

jobs:
build:
uses: ./.github/workflows/container-image.yml
permissions:
packages: write
with:
push-image: true

sign:
needs: build
uses: ./.github/workflows/sign-image.yml
permissions:
packages: write
id-token: write
with:
image-digest: ${{ needs.build.outputs.digest }}

sbom:
needs: build
uses: ./.github/workflows/sbom.yml
permissions:
packages: write
id-token: write
with:
image-digest: ${{ needs.build.outputs.digest }}
62 changes: 62 additions & 0 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build container image

on:
workflow_call:
inputs:
push-image:
type: boolean
required: true
outputs:
repository:
description: "Repository used to build the container image"
value: ${{ jobs.build.outputs.repository }}
version:
description: "Version used to build the container image"
value: ${{ jobs.build.outputs.version }}
digest:
description: "Image digest"
value: ${{ jobs.build.outputs.digest }}

jobs:
build:
name: Build container image
permissions:
packages: write
runs-on: ubuntu-latest
outputs:
repository: ${{ steps.setoutput.outputs.repository }}
version: ${{ steps.setoutput.outputs.version }}
artifact: ${{ steps.setoutput.outputs.artifact }}
digest: ${{ steps.setoutput.outputs.digest }}
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup version info
run: echo "VERSION=$(date +%Y%m%d-%H%M%S)-g$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Build and push container image
if: ${{ inputs.push-image }}
id: build-image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64, linux/arm64
push: true
tags: |
ghcr.io/${{ env.IMG_REPOSITORY_NAME }}/kwasm-operator:${{ env.VERSION }}
- id: setoutput
name: Set output parameters
run: |
echo "repository=ghcr.io/${{ env.IMG_REPOSITORY_NAME }}/kwasm-operator" >> $GITHUB_OUTPUT
echo "version=${{ ${{ env.VERSION }} }}" >> $GITHUB_OUTPUT
echo "digest=${{ steps.build-image.outputs.digest }}" >> $GITHUB_OUTPUT
42 changes: 42 additions & 0 deletions .github/workflows/helm-chart-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This action releases the kwasm-operator helm chart
# The action must run on each commit done against main, however
# a new release will be performed **only** when a change occurs inside
# of the `charts` directory.
name: Release helm chart

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest

permissions:
id-token: write
packages: write
contents: write

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
with:
version: v3.10.0

- name: Run chart-releaser
if: github.ref == 'refs/heads/main'
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NAME_TEMPLATE: "{{ .Name }}-chart-{{ .Version }}"
37 changes: 37 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release Drafter

on:
workflow_dispatch:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize, edited]
# pull_request_target event is required for autolabeler to support PRs from forks
pull_request_target:
types: [opened, reopened, synchronize, edited]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@09c613e259eb8d4e7c81c2cb00618eb5fc4575a7 # v5.25.0
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 63ef857

Please sign in to comment.