CI: fix release pr target (#90999)

* use inputs.target as checkout ref, and `main` for all reused actions.
pull/91004/head
Kevin Minehart 11 months ago committed by GitHub
parent 3137410f3f
commit 2fe506d502
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      .github/workflows/changelog.yml
  2. 23
      .github/workflows/release-pr.yml
  3. 15
      pkg/build/actions/bump-version/action.yml

@ -62,6 +62,7 @@ jobs:
- name: "Checkout Grafana repo" - name: "Checkout Grafana repo"
uses: "actions/checkout@v4" uses: "actions/checkout@v4"
with: with:
ref: main
sparse-checkout: | sparse-checkout: |
.github/workflows .github/workflows
CHANGELOG.md CHANGELOG.md
@ -123,7 +124,7 @@ jobs:
--label "no-backport" \ --label "no-backport" \
--label "no-changelog" \ --label "no-changelog" \
-B "${{ inputs.target }}" \ -B "${{ inputs.target }}" \
--title "Release: ${{ inputs.version }}" \ --title "Release: update changelog for ${{ inputs.version }}" \
--body "Changelog changes for release ${{ inputs.version }}" --body "Changelog changes for release ${{ inputs.version }}"
env: env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }} GH_TOKEN: ${{ steps.generate_token.outputs.token }}

@ -59,9 +59,16 @@ jobs:
- name: Checkout Grafana - name: Checkout Grafana
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ inputs.target }}
fetch-depth: 0 fetch-depth: 0
fetch-tags: true fetch-tags: true
- name: Checkout Grafana (main)
uses: actions/checkout@v4
with:
ref: km/fix-release-pr-target
fetch-depth: '0'
fetch-tags: 'false'
path: .grafana-main
- name: Configure git user - name: Configure git user
run: | run: |
git config --local user.name "github-actions[bot]" git config --local user.name "github-actions[bot]"
@ -70,15 +77,13 @@ jobs:
- name: Create branch - name: Create branch
run: git checkout -b "release/${{ github.run_id }}/${{ inputs.version }}" run: git checkout -b "release/${{ github.run_id }}/${{ inputs.version }}"
- name: Generate changelog - name: Generate changelog
id: changelog id: changelog
uses: ./.github/workflows/actions/changelog uses: ./.grafana-main/.github/workflows/actions/changelog
with: with:
github_token: ${{ steps.generate_token.outputs.token }} github_token: ${{ steps.generate_token.outputs.token }}
target: v${{ inputs.version }} target: v${{ inputs.version }}
output_file: changelog_items.md output_file: changelog_items.md
- name: Patch CHANGELOG.md - name: Patch CHANGELOG.md
run: | run: |
# Prepare CHANGELOG.md content with version delimiters # Prepare CHANGELOG.md content with version delimiters
@ -112,16 +117,16 @@ jobs:
git diff CHANGELOG.md git diff CHANGELOG.md
- name: Commit CHANGELOG.md changes - name: Commit CHANGELOG.md changes
run: git commit --allow-empty -m "Update changelog placeholder" CHANGELOG.md run: git add CHANGELOG.md && git commit --allow-empty -m "Update changelog" CHANGELOG.md
- name: Update package.json versions - name: Update package.json versions
uses: ./pkg/build/actions/bump-version uses: ./.grafana-main/pkg/build/actions/bump-version
with: with:
version: ${{ inputs.version }} version: 'patch'
- name: Add package.json changes - name: Add package.json changes
run: | run: |
git add . git add package.json lerna.json yarn.lock packages public
git commit -m "Update version to ${{ inputs.version }}" git commit -m "Update version to ${{ inputs.version }}"
- name: Git push - name: Git push
@ -133,6 +138,7 @@ jobs:
run: > run: >
gh pr create \ gh pr create \
$( [ "x${{ inputs.latest }}" == "xtrue" ] && printf %s '-l "release/latest"') \ $( [ "x${{ inputs.latest }}" == "xtrue" ] && printf %s '-l "release/latest"') \
-l "no-changelog" \
--dry-run=${{ inputs.dry_run }} \ --dry-run=${{ inputs.dry_run }} \
-B "${{ inputs.target }}" \ -B "${{ inputs.target }}" \
--title "Release: ${{ inputs.version }}" \ --title "Release: ${{ inputs.version }}" \
@ -146,6 +152,7 @@ jobs:
gh pr create \ gh pr create \
$( [ "x${{ inputs.latest }}" == "xtrue" ] && printf %s '-l "release/latest"') \ $( [ "x${{ inputs.latest }}" == "xtrue" ] && printf %s '-l "release/latest"') \
-l "product-approved" \ -l "product-approved" \
-l "no-changelog" \
--dry-run=${{ inputs.dry_run }} \ --dry-run=${{ inputs.dry_run }} \
-B "${{ inputs.target }}" \ -B "${{ inputs.target }}" \
--title "Release: ${{ inputs.version }}" \ --title "Release: ${{ inputs.version }}" \

@ -7,21 +7,6 @@ inputs:
runs: runs:
using: "composite" using: "composite"
steps: steps:
- uses: actions-ecosystem/action-regex-match@v2.0.2
if: ${{ github.event.inputs.version != '' }}
id: regex-match
with:
text: ${{ github.event.inputs.version }}
# https://semver.org/
regex: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
- name: Validate input version
if: ${{ steps.regex-match.outputs.match == '' && github.event.inputs.version != '' }}
shell: bash
run: |
echo "The input version format is not correct, please respect:\
major.minor.patch, major.minor.patch-preview or major.minor.patch-preview<number> format. \
example: 7.4.3, 7.4.3-preview or 7.4.3-preview1"
exit 1
- uses: actions/setup-go@v4 - uses: actions/setup-go@v4
with: with:
go-version-file: go.mod go-version-file: go.mod

Loading…
Cancel
Save