From 7b45fa289eb75203ae78e0dff78b3a0b9b11c250 Mon Sep 17 00:00:00 2001 From: Steve Todorov Date: Sun, 9 Jul 2023 19:25:35 +0300 Subject: [PATCH] build: Incorrect change logs are auto-generated in release prs (#727) --- .github/workflows/bump-snapshot-version.yaml | 2 +- .github/workflows/command-dispatcher.yaml | 5 ++++ .github/workflows/command-help.yaml | 1 + .github/workflows/command-merge-release.yaml | 2 +- .github/workflows/command-merge-snapshot.yaml | 2 +- .github/workflows/prepare-release.yaml | 23 ++++++++++++++----- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bump-snapshot-version.yaml b/.github/workflows/bump-snapshot-version.yaml index ed80a9f8..eb9ca9d3 100644 --- a/.github/workflows/bump-snapshot-version.yaml +++ b/.github/workflows/bump-snapshot-version.yaml @@ -60,7 +60,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} author: "cs-devops-bot " - commit-message: "chore(snapshot): Prepare for v${{ inputs.VERSION }}\n Release-As: ${{ inputs.VERSION }}" + commit-message: "chore(snapshot): Prepare for v${{ inputs.VERSION }}\n\nRelease-As: ${{ inputs.VERSION }}" title: "chore(snapshot): Prepare for v${{ inputs.VERSION }}" body: "" labels: automated pr diff --git a/.github/workflows/command-dispatcher.yaml b/.github/workflows/command-dispatcher.yaml index d4cf89cf..8c2394e5 100644 --- a/.github/workflows/command-dispatcher.yaml +++ b/.github/workflows/command-dispatcher.yaml @@ -30,6 +30,11 @@ jobs: "permission": "write", "issue_type": "pull-request" }, + { + "command": "update-release", + "permission": "write", + "issue_type": "pull-request" + }, { "command": "deploy-pr", "permission": "write", diff --git a/.github/workflows/command-help.yaml b/.github/workflows/command-help.yaml index bcae387d..8b7b8ba1 100644 --- a/.github/workflows/command-help.yaml +++ b/.github/workflows/command-help.yaml @@ -27,5 +27,6 @@ jobs: > --- | --- > /merge-snapshot | Squash and merge snapshot PR. > /merge-release | Squash and merge release PR. + > /update-release | Updates the changelog of a release PR. > /deploy-pr | Deploys the PR as a snapshot version (i.e. `org.carlspring.cloud.aws:s3fs-nio:PR-${{ github.event.client_payload.github.payload.issue.number }}-SNAPSHOT` using ref `${{ github.event.client_payload.pull_request.head.sha }}`) reaction-type: hooray diff --git a/.github/workflows/command-merge-release.yaml b/.github/workflows/command-merge-release.yaml index 36dcaedd..bba89ff8 100644 --- a/.github/workflows/command-merge-release.yaml +++ b/.github/workflows/command-merge-release.yaml @@ -31,7 +31,7 @@ jobs: const isRelease = prTitle.includes("Release v") if(!isRelease) { console.log("") - console.error("/merge-snapshot is supposed to be executed only on pull requests updating the version to snapshot!") + console.error("/merge-release is supposed to be executed only on pull requests updating the version to a release!") console.log("") process.exit(1) } diff --git a/.github/workflows/command-merge-snapshot.yaml b/.github/workflows/command-merge-snapshot.yaml index 9baf701b..5a31ba59 100644 --- a/.github/workflows/command-merge-snapshot.yaml +++ b/.github/workflows/command-merge-snapshot.yaml @@ -51,7 +51,7 @@ jobs: const commit_raw_title = split[0]; const commit_title = commit_raw_title + " (#${{ github.event.client_payload.github.payload.issue.number }})" split.shift() - let commit_message = (split.join('\n') + "\n\nCo-authored-by: " + commits[0].author.name + " <" + commits[0].author.email + ">").trim(); + let commit_message = (split.join('\n') + "\nCo-authored-by: " + commits[0].author.name + " <" + commits[0].author.email + ">").trim(); console.log("Squash title: " + commit_title); console.log("Squash message: \n" + commit_message + "\n/Squash message\n"); await github.rest.pulls.merge({ diff --git a/.github/workflows/prepare-release.yaml b/.github/workflows/prepare-release.yaml index c264f206..b61628cc 100644 --- a/.github/workflows/prepare-release.yaml +++ b/.github/workflows/prepare-release.yaml @@ -1,6 +1,8 @@ on: workflow_dispatch: workflow_call: + repository_dispatch: + types: [ update-release-command ] permissions: contents: write @@ -10,12 +12,21 @@ name: Prepare release jobs: prepare-release: + if: | + ${{ github.repository == vars.CURRENT_REPO }} && + ${{ (github.triggering_actor == 'carlspring' || github.triggering_actor == 'steve-todorov') == true }} runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v3 - id: release + - uses: actions/checkout@v3 with: - # https://github.com/googleapis/release-please/blob/main/src/changelog-notes.ts#L42 - command: manifest - # This is required to avoid `release-please failed: API rate limit exceeded for installation ID XYZ` - token: ${{ secrets.GITHUB_TOKEN }} + ref: 'master' + fetch-depth: 1 + + - uses: actions/setup-node@v3 + + - name: Install release-please + run: npm install -g release-please + + - name: Release + run: | + release-please --token=${{ secrets.GITHUB_TOKEN }} --repo-url=${{ vars.CURRENT_REPO }} release-pr --release-type simple --pull-request-title-pattern "Release v\${version}" --extra-files gradle.properties,docs/mkdocs.yaml,docs/mkdocs.yml