|
| 1 | +# This workflow will release Distributed Workloads stack |
| 2 | + |
| 3 | +name: Tag and Release |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + release-version: |
| 8 | + description: 'Release version of Distributed Workloads stack (i.e. v0.0.0)' |
| 9 | + required: true |
| 10 | + operator-version: |
| 11 | + description: 'Published version of operator image (i.e. v0.0.0)' |
| 12 | + required: true |
| 13 | + mcad-version: |
| 14 | + description: 'Published version of multi-cluster-app-dispatcher (i.e. v0.0.0)' |
| 15 | + required: true |
| 16 | + codeflare-sdk-version: |
| 17 | + description: 'Published version of CodeFlare-SDK (i.e. v0.0.0)' |
| 18 | + required: true |
| 19 | + instascale-version: |
| 20 | + description: 'Published version of InstaScale (i.e. v0.0.0)' |
| 21 | + required: true |
| 22 | + kuberay-version: |
| 23 | + description: 'Published version of KubeRay (i.e. v0.0.0)' |
| 24 | + required: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + push: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + # Permission required to create a release |
| 31 | + permissions: |
| 32 | + contents: write |
| 33 | + pull-requests: write |
| 34 | + |
| 35 | + env: |
| 36 | + PR_BRANCH_NAME: adjustments-release-${{ github.event.inputs.release-version }} |
| 37 | + |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v3 |
| 40 | + |
| 41 | + - name: Set Go |
| 42 | + uses: actions/setup-go@v3 |
| 43 | + with: |
| 44 | + go-version: v1.19 |
| 45 | + |
| 46 | + - name: Verify that release doesn't exist yet |
| 47 | + shell: bash {0} |
| 48 | + run: | |
| 49 | + gh release view ${{ github.event.inputs.release-version }} |
| 50 | + status=$? |
| 51 | + if [[ $status -eq 0 ]]; then |
| 52 | + echo "Release ${{ github.event.inputs.release-version }} already exists." |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ github.TOKEN }} |
| 57 | + |
| 58 | + - name: Adjust Compatibility Matrix in readme |
| 59 | + run: | |
| 60 | + sed -i -E "s/(.*CodeFlare Operator.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.operator-version }}\2/" README.md |
| 61 | + sed -i -E "s/(.*Multi-Cluster App Dispatcher.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.mcad-version }}\2/" README.md |
| 62 | + sed -i -E "s/(.*CodeFlare-SDK.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.codeflare-sdk-version }}\2/" README.md |
| 63 | + sed -i -E "s/(.*InstaScale.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.instascale-version }}\2/" README.md |
| 64 | + sed -i -E "s/(.*KubeRay.*)v[0-9]+\.[0-9]+\.[0-9]+(.*)/\1${{ github.event.inputs.kuberay-version }}\2/" README.md |
| 65 | +
|
| 66 | + - name: Adjust dependencies in the tests |
| 67 | + run: | |
| 68 | + go get github.com/project-codeflare/codeflare-operator@${{ github.event.inputs.operator-version }} |
| 69 | + go mod tidy |
| 70 | + working-directory: tests |
| 71 | + |
| 72 | + - name: Adjust CodeFlare notebook ImageStream |
| 73 | + run: | |
| 74 | + sed -i -E "s|(.*name: )v[0-9]+\.[0-9]+\.[0-9]+|\1${{ github.event.inputs.codeflare-sdk-version }}|" codeflare-notebook-imagestream.yaml |
| 75 | + sed -i -E "s|(.*name: quay.io/project-codeflare/notebook:)v[0-9]+\.[0-9]+\.[0-9]+|\1${{ github.event.inputs.codeflare-sdk-version }}|" codeflare-notebook-imagestream.yaml |
| 76 | + working-directory: codeflare-stack/base |
| 77 | + |
| 78 | + - name: Commit changes in the code back to repository |
| 79 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 80 | + with: |
| 81 | + commit_message: Update dependency versions for release ${{ github.event.inputs.release-version }} |
| 82 | + file_pattern: 'README.md *.yaml tests/go.mod tests/go.sum' |
| 83 | + create_branch: true |
| 84 | + branch: ${{ env.PR_BRANCH_NAME }} |
| 85 | + |
| 86 | + - name: Create a PR with code changes |
| 87 | + run: | |
| 88 | + GIT_BRANCH=${GITHUB_REF#refs/heads/} |
| 89 | + gh pr create --base "$GIT_BRANCH" --fill --head "${{ env.PR_BRANCH_NAME }}" --label "lgtm" --label "approved" |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} |
| 92 | + |
| 93 | + - name: Wait until PR with code changes is merged |
| 94 | + run: | |
| 95 | + timeout 7200 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' |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ github.TOKEN }} |
| 98 | + |
| 99 | + - name: Delete remote branch |
| 100 | + run: | |
| 101 | + git push origin --delete ${{ env.PR_BRANCH_NAME }} |
| 102 | +
|
| 103 | + - name: Creates a release in GitHub |
| 104 | + run: | |
| 105 | + gh release create ${{ github.event.inputs.release-version }} --target ${{ github.ref }} --generate-notes |
| 106 | + # Edit notes to add there compatibility matrix |
| 107 | + sed --null-data -E "s/(.*<\!-- Compatibility Matrix start -->)(.*)(<\!-- Compatibility Matrix end -->.*)/\2/" README.md > release-notes.md |
| 108 | + echo "" >> release-notes.md |
| 109 | + echo "Upstream release notes can be found at https://github.com/project-codeflare/codeflare-operator/releases/tag/${{ github.event.inputs.operator-version }}" >> release-notes.md |
| 110 | + echo "" >> release-notes.md |
| 111 | + echo "$(gh release view --json body --jq .body)" >> release-notes.md |
| 112 | + gh release edit ${{ github.event.inputs.release-version }} --notes-file release-notes.md |
| 113 | + rm release-notes.md |
| 114 | + env: |
| 115 | + GITHUB_TOKEN: ${{ github.TOKEN }} |
| 116 | + shell: bash |
0 commit comments