InstaScale Release #9
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 release the InstaScale repository: build an image for the instascale-controller, then push the image to the `project-codeflare` quay repo | |
name: InstaScale Release | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Release tag (for example: v0.0.0)' | |
required: true | |
mcad-version: | |
description: 'Published version of multi-cluster-app-dispatcher to be used as a dependency for InstaScale (for example: v0.0.0)' | |
required: true | |
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: false | |
default: 'project-codeflare' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
# Permission required to create a release | |
permissions: | |
contents: write | |
env: | |
PR_BRANCH: update-release-${{ github.event.inputs.tag }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Verify that release doesn't exist yet | |
shell: bash {0} | |
run: | | |
gh release view ${{ github.event.inputs.tag }} | |
status=$? | |
if [[ $status -eq 0 ]]; then | |
echo "Release ${{ github.event.inputs.tag }} already exists." | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ github.TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19 | |
- name: Update to specific version of multi-cluster-app-dispatcher dependency | |
run: | | |
go get github.com/project-codeflare/multi-cluster-app-dispatcher@${{ github.event.inputs.mcad-version }} | |
# Build and test repository to make sure that MCAD update didn't break anything | |
- name: Build | |
run: go build -o bin/manager main.go | |
- name: Test | |
run: go test -v ./... | |
# Build and push the image | |
- name: Login to Quay.io | |
uses: redhat-actions/podman-login@v1 | |
with: | |
username: ${{ secrets.QUAY_ID }} | |
password: ${{ secrets.QUAY_TOKEN }} | |
registry: quay.io | |
- name: Image Build and Push | |
run: | | |
make image-build -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/instascale-controller:${{ github.event.inputs.tag }} | |
make image-push -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/instascale-controller:${{ github.event.inputs.tag }} | |
- name: Image Push as stable tag | |
if: ${{ inputs.is-stable }} | |
run: | | |
podman tag quay.io/${{ github.event.inputs.quay-organization }}/instascale-controller:${{ github.event.inputs.tag }} quay.io/${{ github.event.inputs.quay-organization }}/instascale-controller:stable | |
make image-push -e IMG=quay.io/${{ github.event.inputs.quay-organization }}/instascale-controller:stable | |
# Update dependencies | |
- name: Commit go.mod and go.sum changes to the branch | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Update go.mod and go.sum to MCAD ${{ github.event.inputs.mcad-version }} | |
file_pattern: 'go.mod go.sum' | |
create_branch: true | |
branch: ${{ env.PR_BRANCH }} | |
- name: Create a Pull request with code changes | |
run: | | |
if git branch -a | grep "${{ env.PR_BRANCH }}"; then | |
GIT_BRANCH=${GITHUB_REF#refs/heads/} | |
gh pr create --base "$GIT_BRANCH" --fill --head "${{ env.PR_BRANCH }}" --label "lgtm" --label "approved" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} | |
- name: Wait for PR to merge | |
run: | | |
if git branch -a | grep "${{ env.PR_BRANCH }}"; then | |
timeout 3600 bash -c 'until [[ $(gh pr view '${{ env.PR_BRANCH }}' --json state --jq .state) == "MERGED" ]]; do sleep 5 && echo "$(gh pr view '${{ env.PR_BRANCH }}' --json state --jq .state)"; done' | |
fi | |
env: | |
GITHUB_TOKEN: ${{ github.TOKEN }} | |
- name: Delete the PR branch | |
run: | | |
if git branch -a | grep "${{ env.PR_BRANCH }}"; then | |
git push origin --delete "${{ env.PR_BRANCH }}" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} | |
# Create a release in InstaScale | |
- name: Creates a release in GitHub | |
run: | | |
gh release create ${{ github.event.inputs.tag }} --target ${{ github.ref }} --generate-notes | |
env: | |
GITHUB_TOKEN: ${{ github.TOKEN }} | |
shell: bash |