Skip to content

Commit 7e52925

Browse files
authored
ci: add release please automation (#1065) (#1070)
1 parent 00b0ac1 commit 7e52925

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "8.19.0"
3+
}

.github/release-please-config.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"release-type": "go",
4+
"include-component-in-tag": false,
5+
"include-v-in-tag": true,
6+
"versioning": "always-bump-patch",
7+
"packages": {
8+
".": {
9+
"version-file": "internal/version/version.go"
10+
}
11+
},
12+
"plugins": [
13+
{
14+
"type": "sentence-case"
15+
}
16+
]
17+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- '[0-9]*.[0-9]*'
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
id-token: write
13+
14+
jobs:
15+
release:
16+
name: Release Please
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Fetch ephemeral GitHub token
20+
id: fetch-token
21+
uses: elastic/ci-gh-actions/fetch-github-token@8a7604dfdd4e7fe21f969bfe9ff96e17635ea577 # v1.0.0
22+
with:
23+
vault-instance: "ci-prod"
24+
25+
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
26+
id: release-please
27+
with:
28+
config-file: .github/release-please-config.json
29+
manifest-file: .github/.release-please-manifest.json
30+
target-branch: ${{ github.ref_name }}
31+
token: ${{ steps.fetch-token.outputs.token }}
32+
33+
- name: Checkout repository
34+
if: steps.release-please.outputs.release_created == 'true'
35+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
36+
with:
37+
token: ${{ steps.fetch-token.outputs.token }}
38+
39+
- name: Bump Version Snapshot
40+
id: bump-version
41+
if: steps.release-please.outputs.release_created == 'true'
42+
run: |
43+
NEXT_PATCH=$((${{ steps.release-please.outputs.patch }} + 1))
44+
NEXT_VERSION="${{ steps.release-please.outputs.major }}.${{ steps.release-please.outputs.minor }}.${NEXT_PATCH}-SNAPSHOT"
45+
echo "Next version: $NEXT_VERSION"
46+
sed -i "s/const Version = \".*\"/const Version = \"$NEXT_VERSION\"/" internal/version/version.go
47+
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
48+
49+
50+
- name: Create Version Bump Pull Request
51+
if: steps.release-please.outputs.release_created == 'true'
52+
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9
53+
with:
54+
token: ${{ steps.fetch-token.outputs.token }}
55+
commit-message: 'chore: bump version to ${{ steps.bump-version.outputs.next_version }}'
56+
branch: chore/bump-version-${{ steps.bump-version.outputs.next_version }}
57+
delete-branch: true
58+
title: 'chore: bump version to ${{ steps.bump-version.outputs.next_version }}'
59+
body: |
60+
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 }}.
61+
62+
Auto-generated by GitHub Actions.
63+
base: ${{ github.ref_name }}
64+
committer: 'Elastic Machine <elasticmachine@users.noreply.github.com>'
65+
author: 'Elastic Machine <elasticmachine@users.noreply.github.com>'

internal/version/version.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@
1818
package version
1919

2020
// Client returns the client version as a string.
21-
const Client = "8.19.1-SNAPSHOT"
21+
const Client = Version
22+
23+
// Version is the version of the client.
24+
const Version = "8.19.1-SNAPSHOT"

0 commit comments

Comments
 (0)