From 2fe506d5027ea356bcc92d5c1daa8c9a53b7174c Mon Sep 17 00:00:00 2001 From: Kevin Minehart <5140827+kminehart@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:14:29 -0500 Subject: [PATCH] CI: fix release pr target (#90999) * use inputs.target as checkout ref, and `main` for all reused actions. --- .github/workflows/changelog.yml | 3 ++- .github/workflows/release-pr.yml | 23 +++++++++++++++-------- pkg/build/actions/bump-version/action.yml | 15 --------------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index a8da3095e9e..48246cc7f42 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -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 }} diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 284eb083de4..dc7fe61f85e 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -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 }}" \ diff --git a/pkg/build/actions/bump-version/action.yml b/pkg/build/actions/bump-version/action.yml index c93d251a47a..783145097a2 100644 --- a/pkg/build/actions/bump-version/action.yml +++ b/pkg/build/actions/bump-version/action.yml @@ -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 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