Prepare Release #14
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
| # Copyright (c) Mondoo, Inc. | |
| # SPDX-License-Identifier: BUSL-1.1 | |
| name: Prepare Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release version (e.g., 13.0.2) — without the 'v' prefix" | |
| required: true | |
| type: string | |
| jobs: | |
| prepare-release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Import environment variables from file | |
| run: cat ".github/env" >> $GITHUB_ENV | |
| - name: Setup Go | |
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: Install yq | |
| run: | | |
| sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
| sudo chmod +x /usr/local/bin/yq | |
| - name: Set version | |
| id: version | |
| run: | | |
| VERSION="${{ inputs.version }}" | |
| # Strip leading 'v' if accidentally included | |
| VERSION="${VERSION#v}" | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "tag=v${VERSION}" >> $GITHUB_OUTPUT | |
| - name: Update version files | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Update Chart.yaml | |
| yq -i ".version = \"${VERSION}\"" charts/mondoo-operator/Chart.yaml | |
| yq -i ".appVersion = \"${VERSION}\"" charts/mondoo-operator/Chart.yaml | |
| # Update kustomization.yaml | |
| yq -i ".images[0].newTag = \"v${VERSION}\"" config/manager/kustomization.yaml | |
| - name: Generate manifests and Helm chart | |
| run: | | |
| make manifests | |
| CHART_NAME=charts/mondoo-operator make helm/crds | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Create release branch and PR | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| TAG="${{ steps.version.outputs.tag }}" | |
| BRANCH="release/${TAG}" | |
| git checkout -b "${BRANCH}" | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit — version files are already up to date" | |
| exit 0 | |
| fi | |
| git commit -m "🚀 Release ${TAG}" | |
| git push origin "${BRANCH}" | |
| gh pr create \ | |
| --title "🚀 Release ${TAG}" \ | |
| --body "$(cat <<EOF | |
| ## Release ${TAG} | |
| This PR updates version files for the ${TAG} release. | |
| ### Changed files | |
| - \`charts/mondoo-operator/Chart.yaml\` — version and appVersion → ${VERSION} | |
| - \`config/manager/kustomization.yaml\` — image tag → ${TAG} | |
| - Generated manifests and Helm CRDs | |
| ### After merging | |
| [Create a new GitHub Release](https://github.com/${{ github.repository }}/releases/new?tag=${TAG}&target=main&title=${TAG}) with tag \`${TAG}\` targeting \`main\`. | |
| The **Publish** workflow will then build and push container images and the Helm chart. | |
| EOF | |
| )" \ | |
| --base main \ | |
| --head "${BRANCH}" |