Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): add release-please for release-automation #1195

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: release-please

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: "${{ steps.release-please.outputs.release_created }}"
release_tag: "${{ steps.release-please.outputs.tag_name }}"

steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
# https://github.com/actions/checkout/issues/1467
fetch-depth: 0

- uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4.1.3
id: release-please
with:
config-file: .release-please.json
manifest-file: .release-please-manifest.json
github-token: ${{ github.secret }}

# If a release was created, also create the binaries and attach them
release-binaries:
runs-on: ubuntu-latest
needs:
- release-please
if: needs.release-please.outputs.release_created

steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
# https://github.com/actions/checkout/issues/1467
fetch-depth: 0
ref: "${{ needs.release-please.outputs.release_tag }}"

- name: Look up release
id: lookup-release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const currentTag = "${{ needs.release-please.outputs.release_tag }}";
core.info(`Looking for release associated with '${currentTag}'`);
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: currentTag
});
core.info(`Release found: ${release.data.id}'`);
core.setOutput('release_id', release.data.id);


- uses: ./.github/actions/setup-goversion

- name: Build binaries
run: make cross

- name: Attach binaries
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ github.token }}
script: |
const path = require('node:path');
const fs = require('node:fs/promises');

const releaseId = '${{ steps.lookup-release.outputs.release_id }}';
const globber = await glob.create('dist/*');
zerok marked this conversation as resolved.
Show resolved Hide resolved

for await (const file of globber.globGenerator()) {
const filename = path.basename(file);
try {
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: releaseId,
name: filename,
data: await fs.readFile(file),
});
} catch (e) {
if (e.status === 422) {
core.setFailed(`${filename} already attached to release`);
return;
}
throw e;
}
}

50 changes: 0 additions & 50 deletions .github/workflows/release.yml

This file was deleted.

1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{".": "0.29.0"}
60 changes: 60 additions & 0 deletions .release-please.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"changelog-sections": [
{
"section": "🎉 Features",
"type": "feat"
},
{
"section": "🐛 Bug Fixes",
"type": "fix"
},
{
"section": "⚡ Performance Improvements",
"type": "perf"
},
{
"section": "🔗 Dependencies",
"type": "deps"
},
{
"section": "📝 Documentation",
"type": "docs"
},
{
"section": "🏗️ Build System",
"type": "build"
},
{
"section": "🤖 Continuous Integration",
"type": "ci"
},
{
"section": "🔧 Miscellaneous Chores",
"type": "chore"
},
{
"section": "⏪ Reverts",
"type": "revert"
},
{
"section": "✅ Tests",
"type": "test"
},
{
"section": "💄 Style",
"type": "style"
},
{
"section": "♻️ Code Refactoring",
"type": "refactor"
}
],
"draft-pull-request": true,
"include-v-in-tag": true,
"packages": {
".": {
}
},
"release-type": "go"
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

For releases from v0.24.0 forward, you can find the changelog in Github releases: https://github.com/grafana/tanka/releases
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

## 0.23.1 (2022-09-28)

Expand Down
23 changes: 5 additions & 18 deletions docs/src/content/docs/internal/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,10 @@
title: "Releasing a new version"
---

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

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

1. Pull the latest changes from the `main` branch to your local clone.
1. Create a new tag with the prefix `v` (e.g. `v0.28.0`).
1. Push that tag back to GitHub.

This starts multiple GitHub workflows that will produce binaries, a Docker image, and also a new GitHub release that is *marked as draft*.

## 2. Add changelog to the release notes

Once all these actions have finished, go to <https://github.com/grafana/tanka/releases> and you should see the new draft release.
Click the pencil icon ("edit") at the top-right and go to the last line of the text body.
Now hit the "Generate release notes" button to add a changelog to the end of the release notes.

## 3. Publish the release notes

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.
Loading