-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from clobrano/automate-community-bundle-0
Automate community bundle creation
- Loading branch information
Showing
5 changed files
with
203 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,54 +11,26 @@ permissions: | |
pull-requests: read | ||
|
||
jobs: | ||
push-images: | ||
name: Build and push images to quay.io/medik8s | ||
push_to_registry: | ||
name: Build and push unversioned images to quay.io/medik8s | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
|
||
- name: Log in to Quay.io | ||
uses: docker/login-action@v2 | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_PASSWORD }} | ||
registry: quay.io | ||
|
||
- name: Build and push CSV 0.0.1 + latest images for PR merges to main | ||
if: ${{ github.ref_type != 'tag' }} | ||
- name: Build and push CSV version 0.0.1 with latest images | ||
run: export IMAGE_REGISTRY=quay.io/medik8s && make container-build-and-push-community | ||
|
||
- name: Build and push versioned CSV and images for tags | ||
if: ${{ github.ref_type == 'tag' }} | ||
# remove leading 'v' from tag! | ||
run: export VERSION=$(echo $GITHUB_REF_NAME | sed 's/v//') && make container-build-and-push-community | ||
|
||
- name: Create release with manifests | ||
if: ${{ github.ref_type == 'tag' }} | ||
# https://github.com/marketplace/actions/github-release-create-update-and-upload-assets | ||
uses: meeDamian/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: true | ||
body: | | ||
# Node Maintenance Operator ${{ github.ref_name }} | ||
## Notable Changes | ||
* TODO | ||
## Release Artifacts | ||
### Images | ||
* Operator: quay.io/medik8s/node-maintenance-operator:${{ github.ref_name }} | ||
* Bundle: quay.io/medik8s/node-maintenance-operator-bundle:${{ github.ref_name }} | ||
* Catalog aka Index: quay.io/medik8s/node-maintenance-operator-catalog:${{ github.ref_name }} | ||
### Source code and OLM manifests | ||
Please find the source code and the OLM manifests in the `Assets` section below. | ||
gzip: folders | ||
files: > | ||
Manifests:bundle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
operation: | ||
description: "The operation to perform." | ||
required: true | ||
type: choice | ||
default: "build_and_push_images" | ||
options: | ||
- build_and_push_images | ||
- create_okd_release_pr | ||
- create_k8s_release_pr | ||
version: | ||
description: "The version to release, without the leading `v`" | ||
required: true | ||
previous_version: | ||
description: "The previous version, used for the CVS's `replaces` field, without the leading `v`" | ||
required: true | ||
ocp_version: | ||
description: "The target OCP version for the release (mandatory for create_okd_release_pr option)" | ||
required: false | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
push_to_registry: | ||
if: ${{ inputs.operation == 'build_and_push_images' }} | ||
name: Build and push versioned images to quay.io/medik8s | ||
runs-on: ubuntu-22.04 | ||
env: | ||
VERSION: ${{ inputs.version }} | ||
PREVIOUS_VERSION: ${{ inputs.previous_version }} | ||
OCP_VERSION: ${{ inputs.ocp_version }} | ||
steps: | ||
- name: Log inputs | ||
run: | | ||
echo "Building version: ${VERSION}," | ||
echo "which replaces version: ${PREVIOUS_VERSION}." | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
|
||
- name: Log in to Quay.io | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_PASSWORD }} | ||
registry: quay.io | ||
|
||
- name: Build and push versioned CSV and images | ||
run: VERSION=$VERSION PREVIOUS_VERSION=$PREVIOUS_VERSION make container-build-community container-push | ||
|
||
- name: Create release with manifests, for tags | ||
# https://github.com/marketplace/actions/github-release-create-update-and-upload-assets | ||
uses: meeDamian/[email protected] | ||
with: | ||
tag: v${{ inputs.version }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: true | ||
body: | | ||
# Node Maintenance Operator ${{ inputs.version }} | ||
## Notable Changes | ||
* TODO | ||
## Release Artifacts | ||
### Images | ||
* Operator: quay.io/medik8s/node-maintenance-operator:v${{ inputs.version }} | ||
* Bundle: quay.io/medik8s/node-maintenance-operator-bundle:v${{ inputs.version }} | ||
* Catalog aka Index: quay.io/medik8s/node-maintenance-operator-catalog:v${{ inputs.version }} | ||
### Source code and OLM manifests | ||
Please find the source code and the OLM manifests in the `Assets` section below. | ||
gzip: folders | ||
files: > | ||
Manifests:bundle/ | ||
create_k8s_release_pr: | ||
if: inputs.operation == 'create_k8s_release_pr' | ||
uses: medik8s/.github/.github/workflows/release_community_bundle_parametric.yaml@main | ||
secrets: inherit | ||
with: | ||
version: ${{ inputs.version }} | ||
previous_version: ${{ inputs.previous_version }} | ||
community: 'K8S' | ||
make_targets: "bundle-community-k8s" | ||
create_okd_release_pr: | ||
if: inputs.operation == 'create_okd_release_pr' | ||
uses: medik8s/.github/.github/workflows/release_community_bundle_parametric.yaml@main | ||
secrets: inherit | ||
with: | ||
version: ${{ inputs.version }} | ||
previous_version: ${{ inputs.previous_version }} | ||
ocp_version: ${{ inputs.ocp_version }} | ||
community: 'OKD' | ||
make_targets: "bundle-community-okd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
## Compare two semantic version numbers. | ||
## semver_cmp.sh VER1 VER2 is equivalent to test if "VER1 >= VER2" | ||
## Usage: | ||
## - semver_cmp.sh 1.2.3 1.2.4 ## -1 VER1 is < than VER2 | ||
## - semver_cmp.sh 1.2.4 1.2.4 ## 0 VER1 is == to VER2 | ||
## - semver_cmp.sh 1.2.5 1.2.4 ## 1 VER1 is > than VER2 | ||
## other tests | ||
## - semver_cmp.sh 1.2 1.2.4 ## -1 | ||
## - semver_cmp.sh 1.2 1.2 ## 0 | ||
## - semver_cmp.sh 1.3 1.2.9 ## 1 | ||
|
||
if [ "$#" -ne 2 ]; then | ||
echo "Illegal number of parameters" | ||
exit 1 | ||
fi | ||
|
||
if [ "$1" = "$2" ]; then | ||
echo 0 | ||
else | ||
# sort the input and check if it is sorted (quietly). | ||
# `sort` will exit successfully if the given file is already sorted, and exit with status 1 otherwise. | ||
# Since we already excluded that the two versions are equal, if the input is sorted, | ||
# it means the first argument is less than the second one. | ||
# https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html#sort-invocation | ||
printf "%s\n%s\n" "$1" "$2" | sort --version-sort --check=quiet && echo -1 || echo 1 | ||
fi |