The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/.github/workflows/changelog.yml

157 lines
5.1 KiB

name: Generate changelog
on:
workflow_call:
inputs:
previous_version:
type: string
required: false
description: 'The release version (semver, git tag, branch or commit) to use for comparison'
version:
type: string
required: true
description: 'Target release version (semver, git tag, branch or commit)'
target:
required: true
type: string
description: 'The base branch that these changes are being merged into'
dry_run:
required: false
default: false
type: boolean
latest:
required: false
default: false
type: boolean
workflow_dispatch:
inputs:
previous_version:
type: string
required: false
description: 'The release version (semver, git tag, branch or commit) to use for comparison'
version:
type: string
required: true
description: 'Target release version (semver, git tag, branch or commit)'
target:
required: true
type: string
description: 'The base branch that these changes are being merged into'
dry_run:
required: false
default: false
type: boolean
latest:
required: false
default: false
type: boolean
permissions: {}
jobs:
main:
env:
RUN_ID: ${{ github.run_id }}
VERSION: ${{ inputs.version }}
PREVIOUS_VERISON: ${{ inputs.previous_version }}
TARGET: ${{ inputs.target }}
DRY_RUN: ${{ inputs.dry_run }}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
steps:
- name: "Get vault secrets"
id: vault-secrets
uses: grafana/shared-workflows/actions/get-vault-secrets@main
with:
# Secrets placed in the ci/data/repo/grafana/grafana/delivery-bot-app path in Vault
repo_secrets: |
GRAFANA_DELIVERY_BOT_APP_PEM=delivery-bot-app:PRIVATE_KEY
- name: "Generate token"
id: generate_token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
with:
app_id: ${{ vars.DELIVERY_BOT_APP_ID }}
private_key: ${{ env.GRAFANA_DELIVERY_BOT_APP_PEM }}
- name: "Checkout Grafana repo"
uses: "actions/checkout@v4"
with:
ref: main
sparse-checkout: |
.github/workflows
CHANGELOG.md
.nvmrc
.prettierignore
.prettierrc.js
fetch-depth: 0
fetch-tags: true
persist-credentials: false
- name: Setup nodejs environment
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: "Configure git user"
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local --add --bool push.autoSetupRemote true
- name: "Create branch"
run: git checkout -b "changelog/${RUN_ID}/${VERSION}"
- name: "Generate changelog"
id: changelog
uses: ./.github/actions/changelog
with:
previous: ${{ inputs.previous_version }}
github_token: ${{ steps.generate_token.outputs.token }}
target: v${{ inputs.version }}
output_file: changelog_items.md
- name: "Patch CHANGELOG.md"
run: |
# Prepare CHANGELOG.md content with version delimiters
(
echo
echo "# ${VERSION} ($(date '+%F'))"
echo
cat changelog_items.md
) > CHANGELOG.part
# Check if a version exists in the changelog
if grep -q "<!-- ${VERSION} START" CHANGELOG.md ; then
# Replace the content between START and END delimiters
echo "Version ${VERSION} is found in the CHANGELOG.md, patching contents..."
sed -i -e "/${VERSION} START/,/${VERSION} END/{//!d;}" \
-e "/${VERSION} START/r CHANGELOG.part" CHANGELOG.md
else
# Prepend changelog part to the main changelog file
echo "Version $VERSION not found in the CHANGELOG.md"
(
echo "<!-- ${VERSION} START -->"
cat CHANGELOG.part
echo "<!-- ${VERSION} END -->"
cat CHANGELOG.md
) > CHANGELOG.tmp
mv CHANGELOG.tmp CHANGELOG.md
fi
git diff CHANGELOG.md
- name: "Prettify CHANGELOG.md"
run: npx prettier --write CHANGELOG.md
- name: "Commit changelog changes"
run: git add CHANGELOG.md && git commit --allow-empty -m "Update changelog" CHANGELOG.md
- name: "git push"
if: inputs.dry_run != true
run: git push
- name: "Create changelog PR"
run: >
gh pr create \
--dry-run="${DRY_RUN}" \
--label "no-backport" \
--label "no-changelog" \
-B "${TARGET}" \
--title "Release: update changelog for ${VERSION}" \
--body "Changelog changes for release ${VERSION}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}