Skip to content
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
89 changes: 89 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
name: Publish Release

on:
workflow_dispatch:
inputs:
draft:
description: "If true, creates the release as a draft."
required: false
type: boolean
default: false
version:
description: "The optional version number to use for the release."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is used if not provided?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, it's minor bump - would still be good to document both here and in RELEASING.md

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's +1 the patch number of the current latest release if unspecified. The docs can have an overhaul once this is tested and working.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs updated.

required: false
type: string
default: ""

permissions: {}

jobs:
release:
runs-on: [ubuntu-latest]

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

permissions:
contents: read
id-token: write

steps:
- name: Get GitHub token
id: get-token
uses: grafana/shared-workflows/actions/create-github-app-token@ae92934a14a48b94494dbc06d74a81d47fe08a40 # v0.2.2
with:
github_app: grafana-otel-bot
permission_set: default

- name: Get version
id: get-version
shell: pwsh
env:
GH_TOKEN: ${{ steps.get-token.outputs.token }}
NEXT_VERSION: ${{ inputs.version }}
run: |
if (-Not [string]::IsNullOrEmpty(${env:NEXT_VERSION})) {
$nextVersion = [System.Version]::new(${env:NEXT_VERSION}.TrimStart('v'))
} else {
$latestUrl = "${env:GITHUB_API_URL}/repos/${env:GITHUB_REPOSITORY}/releases/latest"
$headers = @{
Authorization = "Bearer ${env:GH_TOKEN}";
Accept = "application/vnd.github+json";
}
$latest = (Invoke-RestMethod -Uri $latestUrl -Headers $headers -ErrorAction Stop).tag_name.TrimStart('v')
$currentVersion = [System.Version]::new($latest)
$nextVersion = [System.Version]::new($currentVersion.Major, $currentVersion.Minor, $currentVersion.Build + 1)
}
$releaseVersion = $nextVersion.ToString()
"version=${releaseVersion}" >> ${env:GITHUB_OUTPUT}
- name: Create release
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DRAFT: ${{ inputs.draft == true }}
VERSION: ${{ steps.get-version.outputs.version }}
with:
github-token: ${{ steps.get-token.outputs.token }}
script: |
const { repo, owner } = context.repo;
const draft = process.env.DRAFT === 'true';
const version = process.env.VERSION;
const tag_name = `v${version}`;
const target_commitish = process.env.DEFAULT_BRANCH;
const name = tag_name;
const { data: release } = await github.rest.repos.createRelease({
owner,
repo,
tag_name,
target_commitish,
name,
draft,
generate_release_notes: true,
});
core.notice(`Created release ${release.name}: ${release.html_url}`);
21 changes: 16 additions & 5 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# Releasing

1. Go to <https://github.com/grafana/docker-otel-lgtm/releases/new>
2. Click on "Choose a tag", enter the tag name (e.g. `v0.1.0`), and click "Create a new tag".
3. Click on "Generate release notes" to auto-generate the release notes based on
the commits since the last release.
4. Click on "Publish release".
1. Open the [Publish Release workflow][publish-release]
2. Click on the **Run workflow** button
3. If required, enter a specific version number (e.g. `1.2.3`) in the version field. If left
blank, the version will be auto-incremented to the next patch version based on the
[latest release][latest-release].
4. Wait for the workflow to complete successfully.
5. Click the link in the workflow run summary to the untagged release created by the workflow.
6. Click the edit button (pencil icon) at the top right of the release notes.
7. Verify that the release notes are correct. Make any manual adjustments if necessary.
8. Click on **Publish release**.

<!-- editorconfig-checker-disable -->
<!-- markdownlint-disable MD013 -->

[latest-release]: https://github.com/grafana/docker-otel-lgtm/releases/latest
[publish-release]: https://github.com/grafana/docker-otel-lgtm/actions/workflows/publish-release.yml