-
Notifications
You must be signed in to change notification settings - Fork 164
Add release publishing workflow #868
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cd4d007
Add release publishing workflow
martincostello 23f72b2
Fix lint warnings
martincostello 0f4b7bc
Fix lint warnings
martincostello e7ed023
Fix lint warnings
martincostello ece927d
Test permissions
martincostello dd9192d
Remove test code
martincostello 5e1eeda
Update RELEASING
martincostello ee1d100
Rename workflow
martincostello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." | ||
| required: false | ||
| type: string | ||
| default: "" | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: [ubuntu-latest] | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| permissions: | ||
| contents: read | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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')) | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } 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) | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $releaseVersion = $nextVersion.ToString() | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "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 }} | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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, | ||
zeitlinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
| core.notice(`Created release ${release.name}: ${release.html_url}`); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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**. | ||
|
|
||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <!-- 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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs updated.