diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a1ad8485b2..abc90432f4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,8 +1,14 @@ name: Release +# Builder for the vCluster release pipeline (DEVOPS-1050). The GitHub Release is +# a pipeline OUTPUT, not a trigger: goreleaser creates it at the end of a green +# build. This workflow is dispatched by the loft-sh/github-actions +# vcluster-release action via `gh workflow run release.yaml --ref `, so +# github.ref is refs/tags/ and github.ref_name is the version. It no +# longer triggers on release:created, so a monorepo-created OSS release can never +# re-trigger this builder. on: - release: - types: [created] + workflow_dispatch: jobs: check_minimum_version_tag: @@ -10,11 +16,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - if: ${{ !contains(github.event.release.tag_name, '-') }} + if: ${{ !contains(github.ref_name, '-') }} with: - ref: ${{ github.event.release.tag_name }} + ref: ${{ github.ref_name }} - name: Validate MinimumVersionTag is stable - if: ${{ !contains(github.event.release.tag_name, '-') }} + if: ${{ !contains(github.ref_name, '-') }} run: | MINIMUM_VERSION_TAG=$(grep -oP 'MinimumVersionTag\s*=\s*"\Kv[^"]+' pkg/platform/version.go) if [[ ! "$MINIMUM_VERSION_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then @@ -76,7 +82,10 @@ jobs: run: | RELEASE_VERSION=$(echo "$GITHUB_REF" | sed -nE 's!refs/tags/!!p') echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT" - echo "previous_tag=$(git describe --abbrev=0 --tags "$(git rev-list --tags --skip=1 --max-count=1)")" >> "$GITHUB_OUTPUT" + # Branch-local previous tag: the tag reachable from this commit's + # parent on THIS branch, not the global latest tag (which would be + # wrong on a release branch). See DEVOPS-1050. + echo "previous_tag=$(git describe --tags --abbrev=0 --match 'v*' "${GITHUB_SHA}^" 2>/dev/null || true)" >> "$GITHUB_OUTPUT" - name: Validate semver id: semver uses: loft-sh/github-actions/.github/actions/semver-validation@semver-validation/v1