Tag and Release #50
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 workflow will build the CodeFlare Operator image and push it to the project-codeflare image registry | |
name: Tag and Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Tag to be used for operator image' | |
required: true | |
default: 'v0.0.0-dev' | |
replaces: | |
description: 'The previous semantic version that this tag replaces.' | |
required: true | |
default: 'v0.0.0-dev' | |
codeflare-sdk-version: | |
description: 'Published version of CodeFlare-SDK' | |
required: true | |
default: 'v0.0.0-dev' | |
appwrapper-version: | |
description: 'Tested version of AppWrapper' | |
required: true | |
default: 'v0.0.0-dev' | |
kuberay-version: | |
description: 'Tested version of KubeRay' | |
required: true | |
default: 'v0.0.0-dev' | |
kueue-version: | |
description: 'Tested version of Kueue' | |
required: true | |
default: 'v0.0.0-dev' | |
is-stable: | |
description: 'Select if the built image should be tagged as stable' | |
required: true | |
type: boolean | |
quay-organization: | |
description: 'Quay organization used to push the built images to' | |
required: true | |
default: 'project-codeflare' | |
community-operators-prod-fork-organization: | |
description: 'Owner of forked community-operators-prod repository used to push bundle files to' | |
required: true | |
default: 'project-codeflare' | |
community-operators-prod-organization: | |
description: 'Owner of target community-operators-prod repository used to open a PR against' | |
required: true | |
default: 'redhat-openshift-ecosystem' | |
jobs: | |
push: | |
runs-on: ubuntu-latest | |
# Permission required to create a release | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
IMAGE_ORG_BASE: quay.io/${{ github.event.inputs.quay-organization }} | |
PR_BRANCH_NAME: adjustments-release-${{ github.event.inputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: './go.mod' | |
- name: Verify that release doesn't exist yet | |
shell: bash {0} | |
run: | | |
gh release view ${{ github.event.inputs.version }} | |
status=$? | |
if [[ $status -eq 0 ]]; then | |
echo "Release ${{ github.event.inputs.version }} already exists." | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ github.TOKEN }} | |
- name: Activate cache | |
uses: actions/cache@v4 | |
with: | |
path: /cache | |
key: ${{ runner.os }}-cache-${{ hashFiles('**/go.sum', '.pre-commit-config.yaml') }} | |
- name: Install operator-sdk | |
run: make install-operator-sdk | |
- name: Adjust Compatibility Matrix in readme | |
run: | | |
sed -i -E "s|(.*CodeFlare Operator.*\[).*(\].*releases/tag/).*(\).*)|\1${{ github.event.inputs.version }}\2${{ github.event.inputs.version }}\3|" README.md | |
sed -i -E "s|(.*CodeFlare-SDK.*\[).*(\].*releases/tag/).*(\).*)|\1${{ github.event.inputs.codeflare-sdk-version }}\2${{ github.event.inputs.codeflare-sdk-version }}\3|" README.md | |
sed -i -E "s|(.*AppWrapper.*\[).*(\].*releases/tag/).*(\).*)|\1${{ github.event.inputs.appwrapper-version }}\2${{ github.event.inputs.appwrapper-version }}\3|" README.md | |
sed -i -E "s|(.*KubeRay.*\[).*(\].*releases/tag/).*(\).*)|\1${{ github.event.inputs.kuberay-version }}\2${{ github.event.inputs.kuberay-version }}\3|" README.md | |
sed -i -E "s|(.*Kueue.*\[).*(\].*releases/tag/).*(\).*)|\1${{ github.event.inputs.kueue-version }}\2${{ github.event.inputs.kueue-version }}\3|" README.md | |
- name: Adjust AppWrapper dependency in the code | |
run: | | |
sed -i -E "s/(.*APPWRAPPER_VERSION \?= ).*/\1${{ github.event.inputs.appwrapper-version }}/" Makefile | |
- name: Adjust Kuberay dependency in the code | |
run: | | |
sed -i -E "s/(.*KUBERAY_VERSION \?= ).*/\1${{ github.event.inputs.kuberay-version }}/" Makefile | |
- name: Adjust Kueue dependency in the code | |
run: | | |
sed -i -E "s/(.*KUEUE_VERSION \?= ).*/\1${{ github.event.inputs.kueue-version }}/" Makefile | |
- name: Update image version in params.env | |
run: | | |
VERSION=${{ github.event.inputs.version }} perl -i -pe 's/:(.*)$/:$ENV{"VERSION"}/' config/manager/params.env | |
shell: bash | |
- name: Login to Quay.io | |
id: podman-login-quay | |
run: | | |
podman login --username ${{ secrets.QUAY_ID }} --password ${{ secrets.QUAY_TOKEN }} quay.io | |
- name: Align go.mod and go.sum dependencies for released components | |
run: | | |
make modules | |
- name: Image Build and Push | |
run: | | |
make build | |
make image-build -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:${{ github.event.inputs.version }} | |
make image-push -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:${{ github.event.inputs.version }} | |
- name: Image Push as stable tag | |
if: ${{ inputs.is-stable }} | |
run: | | |
podman tag quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:${{ github.event.inputs.version }} quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:stable | |
make image-push -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/codeflare-operator:stable | |
- name: Cleanup the go.mod and go.sum | |
run: | | |
go mod tidy | |
- name: Regenerate CFO CRD manifests | |
run: | | |
make manifests | |
- name: Commit changes in the code back to repository | |
id: create-pr-branch | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Update dependency versions for release ${{ github.event.inputs.version }} | |
file_pattern: 'README.md *.yaml Makefile go.mod go.sum *.env' | |
create_branch: true | |
branch: ${{ env.PR_BRANCH_NAME }} | |
- name: Create a PR with code changes | |
run: | | |
GIT_BRANCH=${GITHUB_REF#refs/heads/} | |
gh pr create --base "$GIT_BRANCH" --fill --head "${{ env.PR_BRANCH_NAME }}" --label "lgtm" --label "approved" | |
env: | |
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} | |
- name: Wait until PR with code changes is merged | |
id: wait-pr-merge | |
run: | | |
timeout 3600 bash -c 'until [[ $(gh pr view '${{ env.PR_BRANCH_NAME }}' --json state --jq .state) == "MERGED" ]]; do sleep 5 && echo "$(gh pr view '${{ env.PR_BRANCH_NAME }}' --json state --jq .state)"; done' | |
env: | |
GITHUB_TOKEN: ${{ github.TOKEN }} | |
- name: Close PR if PR merge failed | |
if: always() && (steps.wait-pr-merge.outcome == 'failure' || steps.wait-pr-merge.outcome == 'cancelled') | |
run: | | |
gh pr close ${{ env.PR_BRANCH_NAME }} | |
env: | |
GITHUB_TOKEN: ${{ github.TOKEN }} | |
- name: Delete remote branch | |
if: always() && steps.create-pr-branch.outcome == 'success' | |
run: | | |
git push origin --delete ${{ env.PR_BRANCH_NAME }} | |
- name: Creates a release in GitHub | |
run: | | |
gh release create ${{ github.event.inputs.version }} --target ${{ github.ref }} --generate-notes | |
# Edit notes to add there compatibility matrix | |
sed --null-data -E "s/(.*<\!-- Compatibility Matrix start -->)(.*)(<\!-- Compatibility Matrix end -->.*)/\2/" README.md > release-notes.md | |
echo "" >> release-notes.md | |
echo "$(gh release view --json body --jq .body)" >> release-notes.md | |
gh release edit ${{ github.event.inputs.version }} --notes-file release-notes.md | |
rm release-notes.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} | |
shell: bash | |
- name: Build bundle and create PR in OpenShift community operators repository | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "codeflare-machine-account" | |
make openshift-community-operator-release | |
env: | |
VERSION: ${{ github.event.inputs.version }} | |
PREVIOUS_VERSION: ${{ github.event.inputs.replaces }} | |
GH_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} | |
OPERATORS_REPO_FORK_ORG: ${{ github.event.inputs.community-operators-prod-fork-organization }} | |
OPERATORS_REPO_ORG: ${{ github.event.inputs.community-operators-prod-organization }} | |
- name: Logout from Quay.io | |
if: always() && steps.podman-login-quay.outcome == 'success' | |
run: | | |
podman logout quay.io |