Skip to content

Commit

Permalink
Improve actions and build process (#25)
Browse files Browse the repository at this point in the history
Improve Build and release actions:

build and publish container only for release
set controller image version in infrastructure-components.yaml
auto update metadata.yaml
change release action and define release notes based on PR labels
test build on PR
  • Loading branch information
tuxtof authored Apr 29, 2022
1 parent d6f3e7f commit 3d211d7
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 164 deletions.
24 changes: 24 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .github/release.yml

changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 🛠
labels:
- Semver-Major
- breaking-change
- title: Exciting New Features 🎉
labels:
- Semver-Minor
- enhancement
- title: Bug Fixes 🐛
labels:
- bug
- title: Documentation 📖
labels:
- documentation
- title: Other Changes
labels:
- "*"
46 changes: 6 additions & 40 deletions .github/workflows/build-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: build and publish container
name: Test Build

on:
push:

pull_request:


jobs:
build-container:
runs-on: ubuntu-latest
Expand All @@ -13,48 +16,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.17'

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: capi-nutanix
sep-tags: ","
sep-labels: ","
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=sha
- name: Install tools
uses: redhat-actions/openshift-tools-installer@v1
with:
source: "github"
ko: "latest"

- name: Prepare build
run: make test

- name: Build container
env:
KO_DOCKER_REPO: ghcr.io/nutanix-cloud-native/cluster-api-provider-nutanix/controller
TAGS: ${{ steps.meta.outputs.tags }}
LABELS: ${{ steps.meta.outputs.labels }}
PLATFORMS: linux/amd64,linux/arm64,linux/arm
run: |
PTAGS=`echo $TAGS | sed 's/capi-nutanix://g'`
export SOURCE_DATE_EPOCH=$(date +%s)
ko build --bare --image-label "$LABELS" -t "$PTAGS" --platform=$PLATFORMS .
- name: Test build
run: make test build

102 changes: 67 additions & 35 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,91 @@ on:
- 'v*.*.*'

jobs:
release_content:
name: Prepare Release release_content
build_release:
name: Build Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.17'

- name: Install tools
uses: redhat-actions/openshift-tools-installer@v1
with:
source: "github"
kustomize: "latest"
ko: "latest"

- name: build template
run: kustomize build config/default > infrastructure-components.yaml
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: release
uses: actions/create-release@v1
id: create_release
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
draft: false
prerelease: true
release_name: ${{ github.ref }}
tag_name: ${{ github.ref }}
images: capi-nutanix
sep-tags: ","
sep-labels: ","
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=sha
- name: Prepare build
run: make manifests generate

- name: Build container
env:
GITHUB_TOKEN: ${{ github.token }}
KO_DOCKER_REPO: ghcr.io/${{ github.repository }}/controller
TAGS: ${{ steps.meta.outputs.tags }}
LABELS: ${{ steps.meta.outputs.labels }}
PLATFORMS: linux/amd64,linux/arm64,linux/arm
run: |
PTAGS=`echo $TAGS | sed 's/capi-nutanix://g'`
export SOURCE_DATE_EPOCH=$(date +%s)
ko build --bare --image-label "$LABELS" -t "$PTAGS" --platform=$PLATFORMS .
- name: upload infrastructure-components.yaml
uses: actions/upload-release-asset@v1
- name: parse semver
id: semver
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./infrastructure-components.yaml
asset_name: infrastructure-components.yaml
asset_content_type: application/yaml
SEMVER: ${{ steps.meta.outputs.version }}
run: |
n=${SEMVER//[!0-9]/ }
a=(${n//\./ })
echo "::set-output name=major::${a[0]}"
echo "::set-output name=minor::${a[1]}"
- name: upload metadata.yaml
uses: actions/upload-release-asset@v1
- name: build template
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./metadata.yaml
asset_name: metadata.yaml
asset_content_type: application/yaml
NEW_IMG: ghcr.io/${{ github.repository }}/controller:${{ steps.meta.outputs.version }}
run: |
(cd config/manager && kustomize edit set image controller=$NEW_IMG)
kustomize build config/default > infrastructure-components.yaml
- name: upload cluster-template.yaml
uses: actions/upload-release-asset@v1
- name: update metadata.yaml
env:
GITHUB_TOKEN: ${{ github.token }}
MINOR: ${{ steps.semver.outputs.minor }}
MAJOR: ${{ steps.semver.outputs.major }}
run: |
yq -i '(.releaseSeries[] | select(.contract == "v1beta1")).major |= env(MAJOR)' metadata.yaml
yq -i '(.releaseSeries[] | select(.contract == "v1beta1")).minor |= env(MINOR)' metadata.yaml
- name: create release
uses: softprops/action-gh-release@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./cluster-template.yaml
asset_name: cluster-template.yaml
asset_content_type: application/yaml
draft: false
prerelease: true
generate_release_notes: true
files: |
infrastructure-components.yaml
metadata.yaml
cluster-template.yaml
Loading

0 comments on commit 3d211d7

Please sign in to comment.