-
Notifications
You must be signed in to change notification settings - Fork 63
Create GitHub action to automate CodeFlare operator release #138
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
Merged
openshift-merge-robot
merged 1 commit into
project-codeflare:main
from
sutaakar:github-automation
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -7,35 +7,69 @@ on: | |
version: | ||
description: 'Tag to be used for operator image' | ||
required: true | ||
default: '0.0.0-dev' | ||
default: 'v0.0.0-dev' | ||
replaces: | ||
description: 'The previous semantic version that this tag replaces.' | ||
required: true | ||
default: '0.0.0-dev' | ||
default: 'v0.0.0-dev' | ||
mcad-version: | ||
description: 'Published version of multi-cluster-app-dispatcher' | ||
required: true | ||
default: 'v0.0.0-dev' | ||
codeflare-sdk-version: | ||
description: 'Published version of CodeFlare-SDK' | ||
required: true | ||
default: 'v0.0.0-dev' | ||
instascale-version: | ||
description: 'Published version of InstaScale' | ||
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 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- 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@v3 | ||
with: | ||
path: /cache | ||
key: ${{ runner.os }}-cache-${{ hashFiles('**/go.sum', '.pre-commit-config.yaml') }} | ||
|
||
- name: Create tag | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: 'refs/tags/${{ github.event.inputs.version }}', | ||
sha: context.sha | ||
}) | ||
|
||
- name: Install operator-sdk | ||
run: make install-operator-sdk | ||
|
||
|
@@ -46,18 +80,62 @@ jobs: | |
password: ${{ secrets.QUAY_TOKEN }} | ||
registry: quay.io | ||
|
||
- name: Image Build | ||
- name: Image Build and Push | ||
run: | | ||
make build | ||
make bundle | ||
make image-build -e IMG=quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG} | ||
podman tag quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG} quay.io/project-codeflare/codeflare-operator:latest | ||
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: Build bundle and create PR in OpenShift community operators repository | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "CodeFlare CI" | ||
make openshift-community-operator-release | ||
env: | ||
SOURCE_TAG: ${{ github.event.inputs.version }} | ||
VERSION: ${{ github.event.inputs.version }} | ||
PREVIOUS_VERSION: ${{ github.event.inputs.replaces }} | ||
INSTASCALE_VERSION: ${{ github.event.inputs.instascale-version }} | ||
MCAD_VERSION: ${{ github.event.inputs.mcad-version }} | ||
GH_TOKEN: ${{ secrets.GH_PAT }} | ||
IMAGE_ORG_BASE: quay.io/${{ github.event.inputs.quay-organization }} | ||
OPERATORS_REPO_FORK_ORG: ${{ github.event.inputs.community-operators-prod-fork-organization }} | ||
OPERATORS_REPO_ORG: ${{ github.event.inputs.community-operators-prod-organization }} | ||
|
||
- name: Adjust Compatibility Matrix in readme | ||
run: | | ||
sed -i -E "s/(.*CodeFlare Operator.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.version }}\2/" README.md | ||
sed -i -E "s/(.*Multi-Cluster App Dispatcher.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.mcad-version }}\2/" README.md | ||
sed -i -E "s/(.*CodeFlare-SDK.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.codeflare-sdk-version }}\2/" README.md | ||
sed -i -E "s/(.*InstaScale.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" README.md | ||
|
||
- name: Adjust MCAD and InstaScale dependencies in the code | ||
run: | | ||
sed -i -E "s/(.*MCAD_VERSION \?= )v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.mcad-version }}\2/" Makefile | ||
sed -i -E "s/(.*INSTASCALE_VERSION \?= )v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" Makefile | ||
sed -i -E "s/(.*instascale-controller:)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" controllers/testdata/instascale_test_results/case_1/deployment.yaml | ||
sed -i -E "s/(.*instascale-controller:)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" controllers/testdata/instascale_test_results/case_2/deployment.yaml | ||
|
||
- name: Commit readme changes back to repository | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Update dependency versions for release ${{ github.event.inputs.version }} | ||
file_pattern: 'README.md controllers/defaults.go *.yaml *.tmpl Makefile' | ||
|
||
- name: Image Push | ||
- name: Creates a release in GitHub | ||
run: | | ||
make image-push -e IMG=quay.io/project-codeflare/codeflare-operator:${SOURCE_TAG} | ||
make image-push -e IMG=quay.io/project-codeflare/codeflare-operator:latest | ||
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: | ||
SOURCE_TAG: ${{ github.event.inputs.version }} | ||
GITHUB_TOKEN: ${{ github.TOKEN }} | ||
shell: bash |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.