2022-03-23 11:57:51 +00:00
|
|
|
name: Generate Changelog
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
version:
|
|
|
|
required: true
|
|
|
|
description: Release version (e.g. 2022.1.0 or 2022.1.0-beta.0)
|
|
|
|
pull_request:
|
|
|
|
types:
|
|
|
|
- opened
|
|
|
|
- synchronize
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
jobs:
|
2022-04-01 10:10:00 +00:00
|
|
|
parse-version:
|
2022-03-23 11:57:51 +00:00
|
|
|
if: "startsWith(github.head_ref, 'release/') || github.event_name == 'workflow_dispatch'"
|
|
|
|
runs-on: ubuntu-latest
|
2022-04-01 10:10:00 +00:00
|
|
|
outputs:
|
|
|
|
version: ${{ steps.version.outputs.version }}
|
2022-03-23 11:57:51 +00:00
|
|
|
steps:
|
|
|
|
- name: Set release version Env (workflow_dispatch)
|
|
|
|
if: github.event_name == 'workflow_dispatch'
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2022-04-01 10:10:00 +00:00
|
|
|
echo "RELEASE_VERSION=${{ github.event.inputs.version }} " >> $GITHUB_ENV
|
2022-03-23 11:57:51 +00:00
|
|
|
|
|
|
|
- name: Set release version Env (pull_request)
|
|
|
|
if: "startsWith(github.head_ref, 'release/')"
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2022-04-01 10:10:00 +00:00
|
|
|
echo "RELEASE_VERSION=${BRANCH/release\//} " >> $GITHUB_ENV
|
2022-03-23 11:57:51 +00:00
|
|
|
env:
|
|
|
|
BRANCH: ${{ github.head_ref }}
|
|
|
|
|
2022-04-01 10:10:00 +00:00
|
|
|
- name: Save release version as output
|
|
|
|
id: version
|
2022-10-17 12:14:47 +00:00
|
|
|
run: echo "version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
|
2022-04-01 10:10:00 +00:00
|
|
|
env:
|
|
|
|
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
|
|
|
|
|
|
|
|
|
|
|
|
generate-changelog:
|
|
|
|
needs: parse-version
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-03-23 11:57:51 +00:00
|
|
|
- name: Find Pull Request
|
|
|
|
uses: juliangruber/find-pull-request-action@v1
|
|
|
|
id: find-pull-request
|
|
|
|
with:
|
2022-04-01 10:10:00 +00:00
|
|
|
branch: release/${{ needs.parse-version.outputs.version }}
|
2022-03-23 11:57:51 +00:00
|
|
|
|
|
|
|
- name: Setup Node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
|
|
|
|
- name: Get latest release for Changelog
|
|
|
|
id: latest_release
|
|
|
|
uses: cardinalby/git-get-release-action@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
|
|
with:
|
|
|
|
draft: false
|
|
|
|
prerelease: false
|
|
|
|
releaseNameRegEx: Insomnia .*
|
|
|
|
repo: ${{github.repository}}
|
|
|
|
|
|
|
|
- name: Run Changelog-generator script
|
|
|
|
id: changelog
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
npx @kong/changelog-generator generate \
|
|
|
|
--owner ${OWNER} \
|
|
|
|
--repo insomnia \
|
|
|
|
--base ${{ steps.latest_release.outputs.tag_name }} \
|
|
|
|
--head ${HEAD} \
|
|
|
|
--releaseName "${RELEASE_NAME}" > ./temp_changelog.out
|
|
|
|
|
|
|
|
npx @kong/changelog-generator generate \
|
|
|
|
--owner ${OWNER} \
|
|
|
|
--repo insomnia \
|
|
|
|
--base ${{ steps.latest_release.outputs.tag_name }} \
|
|
|
|
--head ${HEAD} \
|
|
|
|
--releaseName "${RELEASE_NAME}" --onlyShowMissing > ./temp_changelog_missing.out
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
OWNER: ${{ github.repository_owner }}
|
2022-04-01 10:10:00 +00:00
|
|
|
HEAD: release/${{ needs.parse-version.outputs.version }}
|
|
|
|
RELEASE_NAME: ${{ needs.parse-version.outputs.version }}
|
2022-03-23 11:57:51 +00:00
|
|
|
|
|
|
|
- name: Read changelog
|
|
|
|
id: read-changelog
|
|
|
|
uses: juliangruber/read-file-action@v1
|
|
|
|
with:
|
|
|
|
path: ./temp_changelog.out
|
|
|
|
|
|
|
|
- name: Read changelog (missing)
|
|
|
|
id: read-changelog-missing
|
|
|
|
uses: juliangruber/read-file-action@v1
|
|
|
|
with:
|
|
|
|
path: ./temp_changelog_missing.out
|
|
|
|
|
|
|
|
- name: Set timestamp
|
|
|
|
id: timestamp
|
2022-10-17 12:14:47 +00:00
|
|
|
run: echo "timestamp=$(date --iso-8601=seconds)" >> $GITHUB_OUTPUT
|
2022-03-23 11:57:51 +00:00
|
|
|
|
|
|
|
- name: Find Comment
|
|
|
|
uses: peter-evans/find-comment@v1
|
|
|
|
id: find-comment
|
|
|
|
with:
|
|
|
|
issue-number: ${{ steps.find-pull-request.outputs.number }}
|
|
|
|
body-includes: Auto-generated changelog
|
|
|
|
|
|
|
|
- name: Create or update comment
|
|
|
|
uses: peter-evans/create-or-update-comment@v1
|
|
|
|
with:
|
|
|
|
comment-id: ${{ steps.find-comment.outputs.comment-id }}
|
|
|
|
issue-number: ${{ steps.find-pull-request.outputs.number }}
|
|
|
|
body: |
|
|
|
|
Auto-generated changelog:
|
|
|
|
```
|
|
|
|
${{ steps.read-changelog.outputs.content }}
|
|
|
|
```
|
|
|
|
|
|
|
|
PRs missing a `changelog(<type>): <description>`:
|
|
|
|
```
|
|
|
|
${{ steps.read-changelog-missing.outputs.content }}
|
|
|
|
```
|
|
|
|
Last Updated: ${{ steps.timestamp.outputs.timestamp }}
|
|
|
|
|
2022-04-01 10:10:00 +00:00
|
|
|
You can download this release header image 🌌 [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
|
|
|
|
2022-03-23 11:57:51 +00:00
|
|
|
To re-trigger:
|
2022-04-01 10:10:00 +00:00
|
|
|
- Via UI, run [Generate Changelog workflow](https://github.com/${{ github.repository }}/actions/workflows/changelog.yml) (`version`): `${{ needs.parse-version.outputs.version }}`
|
2022-03-23 11:57:51 +00:00
|
|
|
- Via CLI, run [Github CLI](https://cli.github.com/):
|
|
|
|
```bash
|
2022-04-01 10:10:00 +00:00
|
|
|
gh workflow run changelog.yml -f version=${{ needs.parse-version.outputs.version }} --repo ${{ github.repository }}
|
2022-03-23 11:57:51 +00:00
|
|
|
```
|
|
|
|
edit-mode: replace
|
2022-04-01 10:10:00 +00:00
|
|
|
|
|
|
|
generate-changelog-image:
|
|
|
|
needs: parse-version
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout branch
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
ref: release/${{ needs.parse-version.outputs.version }}
|
|
|
|
|
|
|
|
- name: Setup Node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version-file: '.nvmrc'
|
|
|
|
|
|
|
|
- name: Bootstrap packages
|
|
|
|
run: npm run bootstrap
|
|
|
|
|
|
|
|
- name: Run changelog-image
|
|
|
|
run: npm run changelog-image
|
|
|
|
|
|
|
|
- name: Upload artifacts
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
if-no-files-found: error
|
|
|
|
name: changelog-image-${{ needs.parse-version.outputs.version }}
|
|
|
|
path: |
|
|
|
|
*.svg
|