Release Fleet against rancher/rancher #556
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
| name: Release Fleet against rancher/rancher | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| fleet_branch: | |
| description: "Fleet branch to release from (main = next unreleased minor version)" | |
| required: true | |
| default: "main" | |
| type: choice | |
| # NOTE: Maintenance required for minor version bumps: | |
| # - New Fleet minor version (every ~4 months): Add new release/v0.X branch below and remove EOL ones | |
| # NOTE: Maintenance required for major version bumps: | |
| # - Rancher major version bump: Update 'dev-v2' and 'release/v2' to 'dev-v3'/'release/v3' in | |
| # compute-rancher-versions.sh (lines with charts_branch and rancher_ref) | |
| # - Fleet major version bump: Update 'v0' pattern in compute-rancher-versions.sh | |
| # (grep -oE 'v0\.[0-9]+') and add new versions to list below | |
| # - Version relationship change: Update rancher_minor calculation in compute-rancher-versions.sh | |
| # (currently: Fleet minor - 1 = Rancher minor) | |
| options: | |
| - main | |
| - release/v0.16 | |
| - release/v0.15 | |
| - release/v0.14 | |
| - release/v0.13 | |
| - release/v0.12 | |
| env: | |
| GOARCH: amd64 | |
| CGO_ENABLED: 0 | |
| jobs: | |
| create-rancher-pr: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| path: fleet | |
| persist-credentials: false | |
| - name: Compute versions | |
| id: versions | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| FLEET_BRANCH: ${{ inputs.fleet_branch }} | |
| run: fleet/.github/scripts/compute-rancher-versions.sh | |
| - name: Checkout rancher/rancher | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| repository: rancher/rancher | |
| ref: ${{ steps.versions.outputs.rancher_ref }} | |
| path: rancher | |
| persist-credentials: false | |
| - name: Pre-flight checks | |
| env: | |
| NEW_FLEET: ${{ steps.versions.outputs.new_fleet }} | |
| run: | | |
| set -euo pipefail | |
| # Skip all checks for pre-releases. | |
| if [[ "${NEW_FLEET}" =~ - ]]; then | |
| echo "Pre-release version ${NEW_FLEET}; skipping pre-flight checks" | |
| exit 0 | |
| fi | |
| # For a new final minor version, pkg/apis and pkg/helmvalues must be tagged in the fleet repo. | |
| if [[ "${NEW_FLEET}" =~ \.0$ ]]; then | |
| for mod in pkg/apis pkg/helmvalues; do | |
| if ! git -C fleet tag -l "${mod}/v${NEW_FLEET}" | grep -q .; then | |
| { | |
| printf 'ERROR: %s/v%s tag not found in the fleet repo!\n' "${mod}" "${NEW_FLEET}" | |
| printf 'For a new final minor version, %s must be bumped first.\n' "${mod}" | |
| printf 'Please create the tag: git tag %s/v%s\n' "${mod}" "${NEW_FLEET}" | |
| } >&2 | |
| exit 1 | |
| fi | |
| done | |
| fi | |
| # For any final version, rancher/rancher must not reference a pre-release Fleet API | |
| # so there must be a Fleet `pkg/apis/v<VERSION>` tag that the api is bumped in this action | |
| if ! git -C fleet tag -l "pkg/apis/v${NEW_FLEET}" | grep -q .; then | |
| # Tag doesn't exist; check if rancher/rancher has a pre-release version that does not need to be bumped. | |
| RANCHER_FLEET_API_VERSION=$(grep 'github.com/rancher/fleet/pkg/apis' rancher/pkg/apis/go.mod | awk '{print $NF}') | |
| if [[ "${RANCHER_FLEET_API_VERSION:-}" =~ - ]]; then | |
| { | |
| printf 'ERROR: rancher/rancher uses pre-release Fleet API %s, but pkg/apis/v%s tag not found\n' "${RANCHER_FLEET_API_VERSION}" "${NEW_FLEET}" | |
| printf 'Please create the tag: git tag pkg/apis/v%s\n' "${NEW_FLEET}" | |
| } >&2 | |
| exit 1 | |
| fi | |
| fi | |
| # Same guard for the pkg/helmvalues module. Rancher may reference it from a different | |
| # go.mod than pkg/apis, and potentially from more than one, so scan all of rancher's | |
| # module files and consider every match (not just the first) to avoid missing a | |
| # pre-release reference in a later file. | |
| # -o restricts the match to "<module> <version>" so a trailing " // indirect" is | |
| # excluded; otherwise awk would read "indirect" as the version and drop the match. | |
| if ! git -C fleet tag -l "pkg/helmvalues/v${NEW_FLEET}" | grep -q .; then | |
| RANCHER_FLEET_HELMVALUES_PRERELEASES=$(grep -rhsoE 'github.com/rancher/fleet/pkg/helmvalues[[:space:]]+v[0-9][^[:space:]]*' rancher --include=go.mod | awk '{print $NF}' | grep -- - | sort -u || true) | |
| if [ -n "${RANCHER_FLEET_HELMVALUES_PRERELEASES}" ]; then | |
| { | |
| printf 'ERROR: rancher/rancher uses pre-release Fleet helmvalues, but pkg/helmvalues/v%s tag not found\n' "${NEW_FLEET}" | |
| printf 'Referenced pre-release version(s): %s\n' "$(echo "${RANCHER_FLEET_HELMVALUES_PRERELEASES}" | tr '\n' ' ')" | |
| printf 'Please create the tag: git tag pkg/helmvalues/v%s\n' "${NEW_FLEET}" | |
| } >&2 | |
| exit 1 | |
| fi | |
| fi | |
| - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 | |
| with: | |
| go-version-file: ./rancher/go.mod | |
| cache-dependency-path: ./rancher/go.sum | |
| - name: Install controller-gen | |
| run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.2 | |
| - name: Run release script | |
| env: | |
| NEW_FLEET: ${{ steps.versions.outputs.new_fleet }} | |
| NEW_CHART: ${{ steps.versions.outputs.new_chart }} | |
| run: | | |
| ./fleet/.github/scripts/release-against-rancher.sh \ | |
| "$NEW_FLEET" \ | |
| "$NEW_CHART" | |
| - name: Create Pull Request | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PUSH_TO_FORKS_SUBMIT_PRS }} | |
| RANCHER_REF: ${{ steps.versions.outputs.rancher_ref }} | |
| NEW_FLEET: ${{ steps.versions.outputs.new_fleet }} | |
| NEW_CHART: ${{ steps.versions.outputs.new_chart }} | |
| working-directory: ./rancher/ | |
| run: | | |
| ../fleet/.github/scripts/create-pr.sh \ | |
| "$RANCHER_REF" \ | |
| "$NEW_FLEET" \ | |
| "$NEW_CHART" \ | |
| rancher |