diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 0000000000..f5d91cebec --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "9.1.0" +} diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 0000000000..b824f17a1f --- /dev/null +++ b/.github/release-please-config.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "go", + "include-component-in-tag": false, + "include-v-in-tag": true, + "versioning": "always-bump-patch", + "packages": { + ".": { + "version-file": "internal/version/version.go" + } + }, + "plugins": [ + { + "type": "sentence-case" + } + ] +} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000000..acfae77f46 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,65 @@ +name: Release + +on: + push: + branches: + - '[0-9]*.[0-9]*' + +permissions: + contents: write + issues: write + pull-requests: write + id-token: write + +jobs: + release: + name: Release Please + runs-on: ubuntu-latest + steps: + - name: Fetch ephemeral GitHub token + id: fetch-token + uses: elastic/ci-gh-actions/fetch-github-token@8a7604dfdd4e7fe21f969bfe9ff96e17635ea577 # v1.0.0 + with: + vault-instance: "ci-prod" + + - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0 + id: release-please + with: + config-file: .github/release-please-config.json + manifest-file: .github/.release-please-manifest.json + target-branch: ${{ github.ref_name }} + token: ${{ steps.fetch-token.outputs.token }} + + - name: Checkout repository + if: steps.release-please.outputs.release_created == 'true' + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + with: + token: ${{ steps.fetch-token.outputs.token }} + + - name: Bump Version Snapshot + id: bump-version + if: steps.release-please.outputs.release_created == 'true' + run: | + NEXT_PATCH=$((${{ steps.release-please.outputs.patch }} + 1)) + NEXT_VERSION="${{ steps.release-please.outputs.major }}.${{ steps.release-please.outputs.minor }}.${NEXT_PATCH}-SNAPSHOT" + echo "Next version: $NEXT_VERSION" + sed -i "s/const Version = \".*\"/const Version = \"$NEXT_VERSION\"/" internal/version/version.go + echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT + + + - name: Create Version Bump Pull Request + if: steps.release-please.outputs.release_created == 'true' + uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9 + with: + token: ${{ steps.fetch-token.outputs.token }} + commit-message: 'chore: bump version to ${{ steps.bump-version.outputs.next_version }}' + branch: chore/bump-version-${{ steps.bump-version.outputs.next_version }} + delete-branch: true + title: 'chore: bump version to ${{ steps.bump-version.outputs.next_version }}' + body: | + Bumps version to ${{ steps.bump-version.outputs.next_version }} after release ${{ steps.release-please.outputs.major }}.${{ steps.release-please.outputs.minor }}.${{ steps.release-please.outputs.patch }}. + + Auto-generated by GitHub Actions. + base: ${{ github.ref_name }} + committer: 'Elastic Machine ' + author: 'Elastic Machine ' diff --git a/internal/version/version.go b/internal/version/version.go index 5e458b0db7..6425177665 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -18,4 +18,7 @@ package version // Client returns the client version as a string. -const Client = "9.1.1-SNAPSHOT" +const Client = Version + +// Version is the version of the client. +const Version = "9.1.1-SNAPSHOT"