CI: fix release pr target (#90999)

* use inputs.target as checkout ref, and `main` for all reused actions.
This commit is contained in:
Kevin Minehart 2024-07-25 16:14:29 -05:00 committed by GitHub
parent 3137410f3f
commit 2fe506d502
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 24 deletions

View File

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

View File

@ -59,9 +59,16 @@ jobs:
- 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: km/fix-release-pr-target
fetch-depth: '0'
fetch-tags: 'false'
path: .grafana-main
- name: Configure git user
run: |
git config --local user.name "github-actions[bot]"
@ -70,15 +77,13 @@ jobs:
- name: Create branch
run: git checkout -b "release/${{ github.run_id }}/${{ inputs.version }}"
- name: Generate changelog
id: changelog
uses: ./.github/workflows/actions/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
@ -112,16 +117,16 @@ jobs:
git diff CHANGELOG.md
- 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
uses: ./pkg/build/actions/bump-version
uses: ./.grafana-main/pkg/build/actions/bump-version
with:
version: ${{ inputs.version }}
version: 'patch'
- name: Add package.json changes
run: |
git add .
git add package.json lerna.json yarn.lock packages public
git commit -m "Update version to ${{ inputs.version }}"
- name: Git push
@ -133,6 +138,7 @@ jobs:
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 }}" \
@ -146,6 +152,7 @@ jobs:
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 }}" \

View File

@ -7,21 +7,6 @@ inputs:
runs:
using: "composite"
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
with:
go-version-file: go.mod