diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 0000000000..7ce0bd0a8c --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,69 @@ +name: Bump DefaultVersion + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + bump-version: + concurrency: + group: bump-default-version + cancel-in-progress: true + if: "!github.event.release.prerelease" + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout master + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: master + + - name: Derive and validate release version + id: version + env: + RAW_TAG: ${{ github.event.release.tag_name }} + run: | + set -euo pipefail + VERSION="${RAW_TAG#v}" + if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "::error::Tag '${RAW_TAG}' is not a stable semver release" + exit 1 + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "Bumping DefaultVersion to $VERSION" + + - name: Update pkg/info/info.go + env: + NEW_VERSION: ${{ steps.version.outputs.version }} + run: | + sed -i "s/^var DefaultVersion = \".*\"/var DefaultVersion = \"${NEW_VERSION}\"/" pkg/info/info.go + grep 'DefaultVersion' pkg/info/info.go + + - name: Create PR + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: bump-default-version + base: master + title: "OCM-00000 | chore: bump DefaultVersion to ${{ steps.version.outputs.version }}" + body: | + ## DefaultVersion bump + + Auto-update `DefaultVersion` in `pkg/info/info.go` to `${{ steps.version.outputs.version }}` + after release `${{ github.event.release.tag_name }}`. + + This keeps the fallback value on master current for local and + non-tagged builds. + + Auto-generated by GitHub Actions. + commit-message: "OCM-00000 | chore: bump DefaultVersion to ${{ steps.version.outputs.version }}" + labels: chore + delete-branch: true + add-paths: "pkg/info/info.go" + sign-commits: true + signoff: true