diff --git a/.github/workflows/release_version_bump.yml b/.github/workflows/release_version_bump.yml index 3ad9633fa4..6842b5f9d6 100644 --- a/.github/workflows/release_version_bump.yml +++ b/.github/workflows/release_version_bump.yml @@ -1,17 +1,21 @@ name: "release: bump version and cut the release" # One entry point for a SeaweedFS release: -# 1. bump MAJOR/MINOR in constants.go and the Helm Chart.yaml, commit to master +# 1. bump MAJOR/MINOR in constants.go and the Helm Chart.yaml, point the +# chart's cosi.image at the newest COSI driver release, commit to master # 2. push the tag, which fans out to the workflows that trigger on # `push: tags` (binaries_release*, container_release_unified, helm_manual_release) # 3. create the GitHub release, with GitHub's generated notes -# 4. dispatch "Prepare release" in seaweedfs-csi-driver and seaweedfs-operator, -# which pick up the new master through `go get -u`, and wait for both +# 4. dispatch "Prepare release" in seaweedfs-csi-driver, seaweedfs-operator and +# seaweedfs-cosi-driver, which pick up the new master through `go get`, and +# wait for all three. The COSI driver image cut here reaches the chart at +# the next release, through step 1. # # Events raised by the default GITHUB_TOKEN do not start other workflows, and it -# cannot reach the other two repositories at all. Add a repo secret RELEASE_PAT -# with `contents: write` here and `actions: write` on the csi-driver and operator -# repos. Without it the tag is still pushed, but nothing downstream of it runs. +# cannot reach the other repositories at all. Add a repo secret RELEASE_PAT +# with `contents: write` here and `actions: write` on the csi-driver, operator +# and cosi-driver repos. Without it the tag is still pushed, but nothing +# downstream of it runs. on: workflow_dispatch: @@ -28,7 +32,7 @@ on: type: string required: false downstream: - description: "Also release the CSI driver and the operator" + description: "Also release the CSI driver, the operator and the COSI driver" type: boolean default: true dry_run: @@ -134,6 +138,43 @@ jobs: sed -i -E "s/^version:.*/version: ${CHART_VERSION}/" "$CHART" cat "$CHART" + - name: Point the chart at the newest COSI driver release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: seaweedfs/seaweedfs-cosi-driver + run: | + set -euo pipefail + VALUES=k8s/charts/seaweedfs/values.yaml + IMAGE="ghcr.io/${REPO}" + CUR=$(grep -oP "^ image: \"${IMAGE}:\K[^\"]+" "$VALUES" || true) + if [ -z "$CUR" ]; then + echo "::warning::no ${IMAGE} image line in ${VALUES}; cosi.image is left alone" + exit 0 + fi + # Not worth failing a release over: keep the current image instead. + if ! NEW=$(timeout 60 gh release view -R "$REPO" --json tagName --jq .tagName); then + echo "::warning::could not read the latest ${REPO} release; cosi.image stays ${CUR}" + exit 0 + fi + if [ "$NEW" = "$CUR" ]; then + echo "cosi.image is already ${CUR}" + exit 0 + fi + if [ "$(printf '%s\n%s\n' "${CUR#v}" "${NEW#v}" | sort -V | tail -n1)" != "${NEW#v}" ]; then + echo "::warning::the latest ${REPO} release ${NEW} is older than ${CUR}; cosi.image stays ${CUR}" + exit 0 + fi + # A release without its image would break every chart install with cosi.enabled. + TOKEN=$(curl -sf --connect-timeout 10 --max-time 30 "https://ghcr.io/token?scope=repository:${REPO}:pull" | jq -r .token || true) + if ! curl -sfI -o /dev/null --connect-timeout 10 --max-time 30 -H "Authorization: Bearer ${TOKEN}" \ + -H 'Accept: application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' \ + "https://ghcr.io/v2/${REPO}/manifests/${NEW}"; then + echo "::warning::${IMAGE}:${NEW} is not pullable; cosi.image stays ${CUR}" + exit 0 + fi + sed -i -E "s|^( image: \"${IMAGE}:)[^\"]+\"|\1${NEW}\"|" "$VALUES" + grep -n "^ image: \"${IMAGE}:" "$VALUES" + - name: Commit, and push the tag id: tag env: @@ -156,7 +197,7 @@ jobs: if git diff --quiet; then echo "::warning::Version files are already at ${TAG}; tagging the current HEAD." else - git add weed/util/version/constants.go k8s/charts/seaweedfs/Chart.yaml + git add weed/util/version/constants.go k8s/charts/seaweedfs/Chart.yaml k8s/charts/seaweedfs/values.yaml git commit -m "${TAG}" git push fi @@ -187,14 +228,20 @@ jobs: include: - repo: seaweedfs/seaweedfs-csi-driver workflow: prepare_release.yaml + ref: master - repo: seaweedfs/seaweedfs-operator workflow: prepare_release.yml + ref: master + - repo: seaweedfs/seaweedfs-cosi-driver + workflow: prepare_release.yaml + ref: main steps: - name: Release ${{ matrix.repo }} env: GH_TOKEN: ${{ secrets.RELEASE_PAT }} REPO: ${{ matrix.repo }} WORKFLOW: ${{ matrix.workflow }} + REF: ${{ matrix.ref }} SHA: ${{ needs.release.outputs.sha }} MODULE: github.com/seaweedfs/seaweedfs run: | @@ -204,7 +251,7 @@ jobs: exit 1 fi - # The dispatched workflow pins seaweedfs with `go get -u ...@latest`, so + # The dispatched workflow pins seaweedfs with `go get ...@latest`, so # wait until the proxy serves the release commit as the tip. Asking for # the commit by name is what makes the proxy fetch it. The proxy can # take longer than five minutes to refresh @latest after a new tag. @@ -231,7 +278,7 @@ jobs: BEFORE=$(released) # A minute early, so runner clock skew cannot hide the run. DISPATCHED_AT=$(date -u -d '1 minute ago' '+%Y-%m-%dT%H:%M:%SZ') - gh workflow run -R "$REPO" "$WORKFLOW" --ref master -f bump=patch -f update_seaweedfs=true + gh workflow run -R "$REPO" "$WORKFLOW" --ref "$REF" -f bump=patch -f update_seaweedfs=true RUN_ID="" for _ in $(seq 12); do