mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 19:54:10 -06:00
8daa6f1f30
* Ensure changelogs are prettified prior to commit * Remove cache property * Include .yarn directory * Include packages directory * Try just using npx * Update workflows
173 lines
6.4 KiB
YAML
173 lines
6.4 KiB
YAML
# 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:
|
|
previous_version:
|
|
type: string
|
|
required: false
|
|
description: 'The release version (semver, git tag, branch or commit) to use for comparison'
|
|
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
|
|
default: false
|
|
type: boolean
|
|
latest:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
push-changelog-to-main:
|
|
name: Create PR to main to update the changelog
|
|
uses: ./.github/workflows/changelog.yml
|
|
with:
|
|
previous_version: ${{inputs.previous_version}}
|
|
version: ${{ inputs.version }}
|
|
latest: ${{ inputs.latest }}
|
|
dry_run: ${{ inputs.dry_run }}
|
|
target: main
|
|
secrets:
|
|
GRAFANA_DELIVERY_BOT_APP_ID: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }}
|
|
GRAFANA_DELIVERY_BOT_APP_PEM: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }}
|
|
create-prs:
|
|
name: Create Release PR
|
|
runs-on: ubuntu-latest
|
|
if: github.repository == 'grafana/grafana'
|
|
steps:
|
|
- 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 }}
|
|
- name: Checkout Grafana
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.target }}
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
- name: Checkout Grafana (main)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: main
|
|
fetch-depth: '0'
|
|
fetch-tags: 'false'
|
|
path: .grafana-main
|
|
- 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 "release/${{ github.run_id }}/${{ inputs.version }}"
|
|
- name: Generate changelog
|
|
id: changelog
|
|
uses: ./.grafana-main/.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: "Prettify CHANGELOG.md"
|
|
run: npx prettier --write CHANGELOG.md
|
|
- name: Commit CHANGELOG.md changes
|
|
run: git add CHANGELOG.md && git commit --allow-empty -m "Update changelog" CHANGELOG.md
|
|
|
|
- name: Update package.json versions
|
|
uses: ./.grafana-main/pkg/build/actions/bump-version
|
|
with:
|
|
version: 'patch'
|
|
|
|
- name: Add package.json changes
|
|
run: |
|
|
git add package.json lerna.json yarn.lock packages public
|
|
git commit -m "Update version to ${{ inputs.version }}"
|
|
|
|
- name: Git push
|
|
if: ${{ inputs.dry_run }} != true
|
|
run: git push --set-upstream origin release/${{ github.run_id }}/${{ inputs.version }}
|
|
|
|
- name: Create PR without backports
|
|
if: "${{ inputs.backport == '' }}"
|
|
run: >
|
|
gh pr create \
|
|
$( [ "x${{ inputs.latest }}" == "xtrue" ] && printf %s '-l "release/latest"') \
|
|
-l "no-changelog" \
|
|
--dry-run=${{ inputs.dry_run }} \
|
|
-B "${{ inputs.target }}" \
|
|
--title "Release: ${{ inputs.version }}" \
|
|
--body "These code changes must be merged after a release is complete"
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create PR with backports
|
|
if: "${{ inputs.backport != '' }}"
|
|
run: >
|
|
gh pr create \
|
|
$( [ "x${{ inputs.latest }}" == "xtrue" ] && printf %s '-l "release/latest"') \
|
|
-l "product-approved" \
|
|
-l "no-changelog" \
|
|
--dry-run=${{ inputs.dry_run }} \
|
|
-B "${{ inputs.target }}" \
|
|
--title "Release: ${{ inputs.version }}" \
|
|
--body "These code changes must be merged after a release is complete"
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|