2024-06-11 07:50:52 -05:00
|
|
|
# This workflow creates a new PR in Grafana which is triggered after a release is completed.
|
|
|
|
# It should include all code changes that are needed after a release is done. This includes the changelog update and
|
|
|
|
# version bumps, but could include more in the future.
|
|
|
|
# Please refrain from including any processes that do not result in code changes in this workflow. Instead, they should
|
|
|
|
# either be triggered in the release promotion process or in the release comms process (that is triggered by merging
|
|
|
|
# this PR).
|
|
|
|
name: Complete a Grafana release
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
version:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
description: The version of Grafana that is being released
|
|
|
|
target:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
description: The base branch that these changes are being merged into
|
|
|
|
backport:
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
description: Branch to backport these changes to
|
|
|
|
dry_run:
|
|
|
|
required: false
|
2024-06-20 13:15:09 -05:00
|
|
|
default: false
|
2024-06-11 07:50:52 -05:00
|
|
|
type: bool
|
2024-07-08 14:32:28 -05:00
|
|
|
latest:
|
|
|
|
required: false
|
|
|
|
default: false
|
|
|
|
type: bool
|
|
|
|
|
|
|
|
permissions:
|
2024-07-19 11:27:59 -05:00
|
|
|
contents: write
|
2024-07-08 14:32:28 -05:00
|
|
|
pull-requests: write
|
2024-06-11 07:50:52 -05:00
|
|
|
|
|
|
|
jobs:
|
2024-07-19 16:54:59 -05:00
|
|
|
push-changelog-to-main:
|
|
|
|
name: Create PR to main to update the changelog
|
|
|
|
uses: ./.github/workflows/changelog.yml
|
|
|
|
with:
|
|
|
|
version: ${{ inputs.version }}
|
|
|
|
latest: ${{ inputs.latest }}
|
|
|
|
dry_run: ${{ inputs.dry_run }}
|
|
|
|
target: main
|
2024-06-11 07:50:52 -05:00
|
|
|
create-prs:
|
|
|
|
name: Create Release PR
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: github.repository == 'grafana/grafana'
|
|
|
|
steps:
|
2024-07-19 11:27:59 -05:00
|
|
|
- name: Generate bot token
|
|
|
|
id: generate_token
|
|
|
|
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
|
|
|
|
with:
|
|
|
|
app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }}
|
|
|
|
private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }}
|
|
|
|
|
2024-06-11 07:50:52 -05:00
|
|
|
- name: Checkout Grafana
|
|
|
|
uses: actions/checkout@v4
|
2024-07-19 11:27:59 -05:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
fetch-tags: true
|
|
|
|
|
2024-06-11 07:50:52 -05:00
|
|
|
- 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"
|
2024-06-20 13:15:09 -05:00
|
|
|
git config --local --add --bool push.autoSetupRemote true
|
2024-07-19 11:27:59 -05:00
|
|
|
|
2024-06-11 07:50:52 -05:00
|
|
|
- name: Create branch
|
|
|
|
run: git checkout -b "release/${{ github.run_id }}/${{ inputs.version }}"
|
2024-07-19 11:27:59 -05:00
|
|
|
|
2024-06-11 07:50:52 -05:00
|
|
|
- name: Generate changelog
|
2024-07-19 11:27:59 -05:00
|
|
|
id: changelog
|
|
|
|
uses: ./.github/workflows/actions/changelog
|
|
|
|
with:
|
|
|
|
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 "# ${{ inputs.version}} ($(date '+%F'))"
|
|
|
|
echo
|
|
|
|
cat changelog_items.md
|
|
|
|
) > CHANGELOG.part
|
|
|
|
|
|
|
|
# Check if a version exists in the changelog
|
|
|
|
if grep -q "<!-- ${{ inputs.version}} START" CHANGELOG.md ; then
|
|
|
|
# Replace the content between START and END delimiters
|
|
|
|
echo "Version ${{ inputs.version }} is found in the CHANGELOG.md, patching contents..."
|
|
|
|
sed -i -e '/${{ inputs.version }} START/,/${{ inputs.version }} END/{//!d;}' \
|
|
|
|
-e '/${{ inputs.version }} START/r CHANGELOG.part' CHANGELOG.md
|
|
|
|
else
|
|
|
|
# Prepend changelog part to the main changelog file
|
|
|
|
echo "Version ${{ inputs.version }} not found in the CHANGELOG.md"
|
|
|
|
(
|
|
|
|
echo "<!-- ${{ inputs.version }} START -->"
|
|
|
|
cat CHANGELOG.part
|
|
|
|
echo "<!-- ${{ inputs.version }} END -->"
|
|
|
|
cat CHANGELOG.md
|
|
|
|
) > CHANGELOG.tmp
|
|
|
|
mv CHANGELOG.tmp CHANGELOG.md
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f CHANGELOG.part changelog_items.md
|
|
|
|
|
|
|
|
git diff CHANGELOG.md
|
|
|
|
|
|
|
|
- name: Commit CHANGELOG.md changes
|
|
|
|
run: git commit --allow-empty -m "Update changelog placeholder" CHANGELOG.md
|
|
|
|
|
2024-06-20 13:15:09 -05:00
|
|
|
- name: Update package.json versions
|
|
|
|
uses: ./pkg/build/actions/bump-version
|
|
|
|
with:
|
|
|
|
version: ${{ inputs.version }}
|
2024-07-19 11:27:59 -05:00
|
|
|
|
|
|
|
- name: Add package.json changes
|
2024-06-20 13:15:09 -05:00
|
|
|
run: |
|
|
|
|
git add .
|
|
|
|
git commit -m "Update version to ${{ inputs.version }}"
|
2024-07-19 11:27:59 -05:00
|
|
|
|
|
|
|
- name: Git push
|
2024-06-20 13:15:09 -05:00
|
|
|
if: ${{ inputs.dry_run }} != true
|
|
|
|
run: git push
|
2024-07-19 11:27:59 -05:00
|
|
|
|
2024-06-11 07:50:52 -05:00
|
|
|
- name: Create PR without backports
|
2024-06-20 13:15:09 -05:00
|
|
|
if: "${{ inputs.backport == '' }}"
|
2024-06-11 07:50:52 -05:00
|
|
|
run: >
|
2024-07-08 14:32:28 -05:00
|
|
|
gh pr create \
|
2024-07-19 11:27:59 -05:00
|
|
|
$( [ "x${{ inputs.latest }}" == "xtrue" ] && printf %s '-l "release/latest"') \
|
2024-07-08 14:32:28 -05:00
|
|
|
--dry-run=${{ inputs.dry_run }} \
|
|
|
|
-B "${{ inputs.target }}" \
|
|
|
|
--title "Release: ${{ inputs.version }}" \
|
|
|
|
--body "These code changes must be merged after a release is complete"
|
2024-06-11 07:50:52 -05:00
|
|
|
env:
|
2024-07-08 14:32:28 -05:00
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2024-07-19 11:27:59 -05:00
|
|
|
|
2024-06-11 07:50:52 -05:00
|
|
|
- name: Create PR with backports
|
2024-06-20 13:15:09 -05:00
|
|
|
if: "${{ inputs.backport != '' }}"
|
2024-06-11 07:50:52 -05:00
|
|
|
run: >
|
2024-07-08 14:32:28 -05:00
|
|
|
gh pr create \
|
2024-07-19 11:27:59 -05:00
|
|
|
$( [ "x${{ inputs.latest }}" == "xtrue" ] && printf %s '-l "release/latest"') \
|
2024-07-08 14:32:28 -05:00
|
|
|
-l "backport ${{ inputs.backport }}" \
|
|
|
|
-l "product-approved" \
|
|
|
|
--dry-run=${{ inputs.dry_run }} \
|
|
|
|
-B "${{ inputs.target }}" \
|
|
|
|
--title "Release: ${{ inputs.version }}" \
|
|
|
|
--body "These code changes must be merged after a release is complete"
|
2024-06-11 07:50:52 -05:00
|
|
|
env:
|
2024-07-08 14:32:28 -05:00
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|