relnote docs · CI · Single-file install · GitHub Action · Gitea and Forgejo · CHANGELOG.md
Release notes in Bitbucket Pipelines and Azure DevOps Pipelines
On a tag push, download the relnote v0.3.8 zipapp, write RELEASE_NOTES.md for that tag, and keep the file as a pipeline artifact. relnote reads the local clone. It does not call Bitbucket or Azure DevOps.
The tag range
--until is the tag that started the pipeline (BITBUCKET_TAG, or BUILD_SOURCEBRANCHNAME in Azure DevOps). When that ref is itself a tag, relnote starts at the tag before it, so the file is this release. --output RELEASE_NOTES.md --quiet writes the file and does not print it. --quiet without --output or --changelog exits 2.
A clone that stops before the previous tag makes the range wrong. Bitbucket's default depth is the last 50 commits. Azure Pipelines' checkout is shallow unless fetchDepth is 0, and pipelines created after September 2022 do not sync tags unless fetchTags is true. The examples below turn those defaults off.
If the range has no commits, relnote exits 1 and prints relnote: no commits in range SINCE..UNTIL. The step fails. A Full changelog compare link is added only when origin is a github.com remote. A Bitbucket or Azure Repos origin keeps the range line.
Bitbucket Pipelines
Save this as bitbucket-pipelines.yml. Tag pipelines match the glob against the tag, including annotated tags. The default pipeline does not run on a tag push. clone.depth: full is a clone option on the step (the default is 50). BITBUCKET_TAG is set only for a tag pipeline.
image: python:3.12 is the Debian image. It has Python 3.12, git, and curl. The -slim and -alpine tags do not include git. The same four download lines are the pinned install: the v0.3.8 zipapp, SHA256SUMS, and sha256sum -c.
pipelines:
tags:
'v*':
- step:
name: Release notes
image: python:3.12
clone:
depth: full
script:
- curl -fsSL -o relnote https://github.com/loki-inu/relnote/releases/download/v0.3.8/relnote
- curl -fsSL -o SHA256SUMS https://github.com/loki-inu/relnote/releases/download/v0.3.8/SHA256SUMS
- grep ' relnote$' SHA256SUMS | sha256sum -c -
- chmod +x relnote
- ./relnote --version
- ./relnote --until "$BITBUCKET_TAG" --output RELEASE_NOTES.md --quiet
artifacts:
- RELEASE_NOTES.md
artifacts paths are relative to BITBUCKET_CLONE_DIR. Later steps receive the file, and the pipeline result page can download it. That is the publish step. No token.
Downloads API
To keep the file on the repository Downloads page, POST /2.0/repositories/{workspace}/{repo_slug}/downloads. The body is multipart/form-data with one or more fields named files. The same filename replaces the existing download. The response is 201 when the upload succeeds. An API token needs the scope write:repository:bitbucket. An OAuth or Connect app needs repository:write. Pipelines does not inject that token. Add it as a secured repository variable (Repository settings, Pipelines, Repository variables). The example below calls it DOWNLOADS_TOKEN. BITBUCKET_WORKSPACE and BITBUCKET_REPO_SLUG are built in.
- step:
name: Upload RELEASE_NOTES.md
image: python:3.12
script:
- |
set -eu
cp RELEASE_NOTES.md "RELEASE_NOTES-${BITBUCKET_TAG}.md"
curl -fsS -X POST \
-H "Authorization: Bearer ${DOWNLOADS_TOKEN}" \
-F "files=@RELEASE_NOTES-${BITBUCKET_TAG}.md" \
"https://api.bitbucket.org/2.0/repositories/${BITBUCKET_WORKSPACE}/${BITBUCKET_REPO_SLUG}/downloads"
Put that step after the notes step, under the same 'v*' list. The notes artifact is downloaded at the start of the step. The copy gives each tag its own filename, so a later tag does not replace an earlier file.
Azure DevOps Pipelines
Save this as azure-pipelines.yml. CI triggers for Azure Repos Git, and the same block for a GitHub repository, treat branch filters and tag filters as OR. Excluding every branch leaves the tag filter. Tags do not start a pipeline unless tags is set. pr: none turns off the separate pull request trigger. '*' is quoted because a bare * is not a plain string in this YAML.
Build.SourceBranch for a tag is refs/tags/v1.3.0. Build.SourceBranchName is the last segment, v1.3.0, exposed to the script as BUILD_SOURCEBRANCHNAME. The job condition uses the same ref prefix as the GitHubRelease task examples.
trigger:
branches:
exclude:
- '*'
tags:
include:
- v*
pr: none
jobs:
- job: release_notes
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
fetchDepth: 0
fetchTags: true
- task: UsePythonVersion@0
displayName: Python 3.12
inputs:
versionSpec: '3.12'
- script: |
set -eu
base=https://github.com/loki-inu/relnote/releases/download/v0.3.8
curl -fsSL -o relnote "$base/relnote"
curl -fsSL -o SHA256SUMS "$base/SHA256SUMS"
grep ' relnote$' SHA256SUMS | sha256sum -c -
chmod +x relnote
./relnote --version
./relnote --until "$BUILD_SOURCEBRANCHNAME" --output RELEASE_NOTES.md --quiet
displayName: Write RELEASE_NOTES.md
- publish: $(System.DefaultWorkingDirectory)/RELEASE_NOTES.md
artifact: RELEASE_NOTES
fetchDepth: 0 fetches all history and overrides the pipeline setting for shallow fetch. fetchTags: true syncs tags and overrides the Sync tags setting. UsePythonVersion@0 puts Python 3.12 on PATH, which the zipapp shebang (#!/usr/bin/env python3) needs. Quote 3.12. An unquoted 3.10 is parsed as the number 3.1. ubuntu-latest has git, curl, and sha256sum. The publish keyword is the Publish Pipeline Artifact task. targetPath may be a file. The run's artifact is named RELEASE_NOTES.
GitHubRelease task
When this pipeline should also open a GitHub Release, add the task after the script. It needs a GitHub service connection (OAuth or a personal access token) named in gitHubConnection. repositoryName defaults to $(Build.Repository.Name), which is owner/name when the pipeline repository is that GitHub repo. tagSource: gitTag uses the tag on the commit. releaseNotesSource: filePath and releaseNotesFilePath take RELEASE_NOTES.md. addChangeLog defaults to true and would append another list of commits, so set it to false. isDraft defaults to false (published). assets defaults to everything in $(Build.ArtifactStagingDirectory). Point it at the notes file so that default is not what gets uploaded.
- task: GitHubRelease@1
displayName: Draft the GitHub Release
inputs:
gitHubConnection: github-connection
repositoryName: $(Build.Repository.Name)
action: create
target: $(Build.SourceVersion)
tagSource: gitTag
title: $(Build.SourceBranchName)
releaseNotesSource: filePath
releaseNotesFilePath: $(System.DefaultWorkingDirectory)/RELEASE_NOTES.md
assets: $(System.DefaultWorkingDirectory)/RELEASE_NOTES.md
isDraft: true
addChangeLog: false
github-connection is the name you gave the service connection, not a variable Azure DevOps fills in. target defaults to $(Build.SourceVersion), the commit being built. Without a GitHub connection, stop at the publish step. The artifact is the notes.
Flags in these jobs
| Flag | In the examples |
|---|---|
--until TAG | End of the range. A tag here starts the notes at the previous tag. |
--output RELEASE_NOTES.md --quiet | Write the file. Exit 1 if the parent directory is missing. |
--version | Print relnote 0.3.8 before the notes, so the log shows the pin. |
--since REF | Not set above. Use it when the start tag should not be "the tag before --until". |
One package in a monorepo: add --path and --tag-prefix. See monorepo release notes. Other CI systems: GitLab CI, Jenkins, or any CI.