Skip to content

Commit 6918cec

Browse files
authored
chore(ci): add release-please for release-automation (#1195)
* chore(ci): Add release-please for release-automation * Merge release-please and release-binaries workflows * Update manifest * Improve code formatting * Update release guide
1 parent 70d96f8 commit 6918cec

File tree

6 files changed

+163
-69
lines changed

6 files changed

+163
-69
lines changed

.github/workflows/release-please.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
name: release-please
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
release_created: "${{ steps.release-please.outputs.release_created }}"
17+
release_tag: "${{ steps.release-please.outputs.tag_name }}"
18+
19+
steps:
20+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
21+
with:
22+
# https://github.com/actions/checkout/issues/1467
23+
fetch-depth: 0
24+
25+
- uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4.1.3
26+
id: release-please
27+
with:
28+
config-file: .release-please.json
29+
manifest-file: .release-please-manifest.json
30+
github-token: ${{ github.secret }}
31+
32+
# If a release was created, also create the binaries and attach them
33+
release-binaries:
34+
runs-on: ubuntu-latest
35+
needs:
36+
- release-please
37+
if: needs.release-please.outputs.release_created
38+
39+
steps:
40+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
41+
with:
42+
# https://github.com/actions/checkout/issues/1467
43+
fetch-depth: 0
44+
ref: "${{ needs.release-please.outputs.release_tag }}"
45+
46+
- name: Look up release
47+
id: lookup-release
48+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
49+
with:
50+
script: |
51+
const currentTag = "${{ needs.release-please.outputs.release_tag }}";
52+
core.info(`Looking for release associated with '${currentTag}'`);
53+
const release = await github.rest.repos.getReleaseByTag({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
tag: currentTag
57+
});
58+
core.info(`Release found: ${release.data.id}'`);
59+
core.setOutput('release_id', release.data.id);
60+
61+
62+
- uses: ./.github/actions/setup-goversion
63+
64+
- name: Build binaries
65+
run: make cross
66+
67+
- name: Attach binaries
68+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
69+
with:
70+
github-token: ${{ github.token }}
71+
script: |
72+
const path = require('node:path');
73+
const fs = require('node:fs/promises');
74+
75+
const releaseId = '${{ steps.lookup-release.outputs.release_id }}';
76+
const globber = await glob.create('dist/*');
77+
78+
for await (const file of globber.globGenerator()) {
79+
const filename = path.basename(file);
80+
try {
81+
await github.rest.repos.uploadReleaseAsset({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
release_id: releaseId,
85+
name: filename,
86+
data: await fs.readFile(file),
87+
});
88+
} catch (e) {
89+
if (e.status === 422) {
90+
core.setFailed(`${filename} already attached to release`);
91+
return;
92+
}
93+
throw e;
94+
}
95+
}
96+

.github/workflows/release.yml

-50
This file was deleted.

.release-please-manifest.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{".": "0.29.0"}

.release-please.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"changelog-sections": [
4+
{
5+
"section": "🎉 Features",
6+
"type": "feat"
7+
},
8+
{
9+
"section": "🐛 Bug Fixes",
10+
"type": "fix"
11+
},
12+
{
13+
"section": "⚡ Performance Improvements",
14+
"type": "perf"
15+
},
16+
{
17+
"section": "🔗 Dependencies",
18+
"type": "deps"
19+
},
20+
{
21+
"section": "📝 Documentation",
22+
"type": "docs"
23+
},
24+
{
25+
"section": "🏗️ Build System",
26+
"type": "build"
27+
},
28+
{
29+
"section": "🤖 Continuous Integration",
30+
"type": "ci"
31+
},
32+
{
33+
"section": "🔧 Miscellaneous Chores",
34+
"type": "chore"
35+
},
36+
{
37+
"section": "⏪ Reverts",
38+
"type": "revert"
39+
},
40+
{
41+
"section": "✅ Tests",
42+
"type": "test"
43+
},
44+
{
45+
"section": "💄 Style",
46+
"type": "style"
47+
},
48+
{
49+
"section": "♻️ Code Refactoring",
50+
"type": "refactor"
51+
}
52+
],
53+
"draft-pull-request": true,
54+
"include-v-in-tag": true,
55+
"packages": {
56+
".": {
57+
}
58+
},
59+
"release-type": "go"
60+
}

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
For releases from v0.24.0 forward, you can find the changelog in Github releases: https://github.com/grafana/tanka/releases
3+
For releases from v0.24.0 to v0.28.3, you can find the changelog in the GitHub releases: https://github.com/grafana/tanka/releases
44

55
## 0.23.1 (2022-09-28)
66

docs/src/content/docs/internal/releasing.md

+5-18
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,10 @@
22
title: "Releasing a new version"
33
---
44

5-
Releasing a new version of Tanka requires a couple of manual and automated steps.
6-
This guide will give you a runbook on how to do them in the right order.
5+
For releasing Tanka we're using [release-please][].
6+
This workflow manages a release pull-request based on the content of the `main` branch that would update the changelog et al..
7+
Once you want to do a release, merge that prepared pull-request.
8+
release-please will then do all the tagging and GitHub Release creation.
79

8-
## 1. Create a release tag
10+
[release-please]: https://github.com/googleapis/release-please-action
911

10-
1. Pull the latest changes from the `main` branch to your local clone.
11-
1. Create a new tag with the prefix `v` (e.g. `v0.28.0`).
12-
1. Push that tag back to GitHub.
13-
14-
This starts multiple GitHub workflows that will produce binaries, a Docker image, and also a new GitHub release that is *marked as draft*.
15-
16-
## 2. Add changelog to the release notes
17-
18-
Once all these actions have finished, go to <https://github.com/grafana/tanka/releases> and you should see the new draft release.
19-
Click the pencil icon ("edit") at the top-right and go to the last line of the text body.
20-
Now hit the "Generate release notes" button to add a changelog to the end of the release notes.
21-
22-
## 3. Publish the release notes
23-
24-
Once you've check that the release looks fine (e.g. no broken links, no missing version numbers in the download paths) click the "Publish release" button.

0 commit comments

Comments
 (0)