From d1c5af2e4a42291fdb9f04551d5747e772ad03ff Mon Sep 17 00:00:00 2001 From: Kaarina Tungseth Date: Fri, 19 Jul 2024 15:42:22 -0500 Subject: [PATCH] Release notes workflow --- .github/actions/fetch-prs/action.yml | 10 ++++++ .github/actions/fetch-prs/index.js | 31 ++++++++++++++++++ .github/release-drafter.yml | 35 ++++++++++++++++++++ .github/workflows/release-drafter.yml | 46 +++++++++++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 .github/actions/fetch-prs/action.yml create mode 100644 .github/actions/fetch-prs/index.js create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/actions/fetch-prs/action.yml b/.github/actions/fetch-prs/action.yml new file mode 100644 index 0000000000..bc97d4c290 --- /dev/null +++ b/.github/actions/fetch-prs/action.yml @@ -0,0 +1,10 @@ +name: Fetch PRs +description: Fetch PRs from the Kibana repository and update the release notes draft +inputs: + target-repo: + description: 'elastic/kibana' + required: true + default: 'elastic/kibana' +runs: + using: 'node12' + main: 'index.js' diff --git a/.github/actions/fetch-prs/index.js b/.github/actions/fetch-prs/index.js new file mode 100644 index 0000000000..c4040b69c6 --- /dev/null +++ b/.github/actions/fetch-prs/index.js @@ -0,0 +1,31 @@ +const core = require('@actions/core'); +const github = require('@actions/github'); +const fs = require('fs'); + +async function run() { + try { + const targetRepo = core.getInput('elastic/kibana'); + const [owner, repo] = targetRepo.split('/'); + const octokit = github.getOctokit(process.env.GITHUB_TOKEN); + + const { data: pulls } = await octokit.pulls.list({ + owner, + repo, + state: 'closed', + }); + + let releaseNotes = '## Changes from ' + targetRepo + '\n\n'; + for (const pr of pulls) { + if (pr.merged_at) { + releaseNotes += `- ${pr.title} (#${pr.number}) by @${pr.user.login}\n`; + } + } + + fs.writeFileSync('release-notes.asciidoc', releaseNotes); + core.setOutput('release-notes', releaseNotes); + } catch (error) { + core.setFailed(error.message); + } +} + +run(); diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000000..9fa6c3fce2 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,35 @@ +name-template: 'v$NEXT_PATCH_VERSION' +tag-template: 'v$NEXT_PATCH_VERSION' +change-template: '* $TITLE ({$URL[#$NUMBER])' +exclude-labels: + - 'release_note:skip' + - 'Team:Docs' + - 'reverted' + - 'backport' +include-labels: + - 'Feature:Uptime' + - 'Feature:Logs UI' + - 'Team:apm' + - 'Team:APM' + - 'Feature:Metrics UI' + - 'Team:logs-metrics-ui' + - 'Feature:Observability Home' + - 'Team:obs-ux-management' + - 'Team:Obs AI Assistant' + - 'Feature:SLO' +categories: + - title: 'Breaking changes' + collapse-after: 5 + labels: ['release_note:breaking'] + - title: 'Features and enhancements' + collapse-after: 5 + labels: ['release_note:feature', 'release_note:enhancement'] + - title: 'Bug fixes' + collapse-after: 5 + labels: ['release_note:fix'] +template: | + == Elastic {observability} + + $CHANGES + + To view all changes, check https://github.com/$OWNER/$REPO/compare/$PREVIOUS_TAG...$CURRENT_TAG. \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000000..ae493e93b8 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,46 @@ +name: Release notes drafter + +on: + push: + branches: + - main + pull_request: + types: [ closed ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + update_release_draft: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Fetch PRs from another repository + id: fetch_prs + uses: ./.github/actions/fetch-prs + with: + target-repo: 'elastic/kibana' + + - name: Run release notes drafter + id: drafter + uses: release-drafter/release-drafter@v5 + with: + config-name: release-drafter.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Update release notes + run: echo "${{ steps.fetch_prs.outputs.release-notes }}" >> release-notes.asciidoc + + - name: Create release + uses: actions/create-release@v1 + with: + tag_name: ${{ github.event.release.tag_name }} + release_name: ${{ github.event.release.tag_name }} + body_path: release-notes.asciidoc + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}