From 0fdc9fd08aef6e8b56b887c115d0f673245216f5 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Mon, 22 May 2023 17:52:43 +0300 Subject: [PATCH] feat(github): Update changelog workflow and config --- .actrc | 3 +++ .github/tag-changelog-config.js | 11 ++++++---- .github/workflows/changelog.yml | 2 +- .github/workflows/new-release.yml | 35 +++++++++++-------------------- 4 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 .actrc diff --git a/.actrc b/.actrc new file mode 100644 index 0000000..697b891 --- /dev/null +++ b/.actrc @@ -0,0 +1,3 @@ +--container-architecture linux/amd64 +--env-file .env +--secret-file .env diff --git a/.github/tag-changelog-config.js b/.github/tag-changelog-config.js index d982339..3ec1071 100644 --- a/.github/tag-changelog-config.js +++ b/.github/tag-changelog-config.js @@ -13,13 +13,14 @@ module.exports = { { types: ['other', 'Other'], label: 'Other Changes' }, ], - excludeTypes: ['other'], + excludeTypes: [], renderTypeSection: function (label, commits) { - let text = `\n## ${ label }\n` + let text = `\n## ${ label }\n\n` commits.forEach((commit) => { - text += `- ${ commit.subject }\n` + const scope = commit.scope ? `**${ commit.scope }:** ` : '' + text += `- ${ scope }${ commit.subject }\n` }) return text @@ -27,6 +28,8 @@ module.exports = { renderChangelog: function (release, changes) { const now = new Date() - return `# ${ release } - ${ now.toISOString().substring(0, 10) }\n` + changes + '\n\n' + const d = now.toISOString().substring(0, 10); + const header = `# ${ release } - ${ d }\n`; + return header + changes + '\n\n' }, } diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index d503821..0b0c4dd 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -15,7 +15,7 @@ jobs: uses: loopwerk/tag-changelog@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - config_file: .github/tag-changelog-config.js + config_file: ./../.github/tag-changelog-config.js - name: "Echo results" id: output-changelog diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml index dce7044..6bddf09 100644 --- a/.github/workflows/new-release.yml +++ b/.github/workflows/new-release.yml @@ -18,34 +18,23 @@ jobs: steps: - uses: actions/checkout@v3 # Checkout our working repository - - uses: fregante/daily-version-action@v2 - name: Create tag if necessary + - name: Create tag if necessary + uses: fregante/daily-version-action@v2 id: daily-version - - name: Conventional Changelog Action + - name: Create changelog text if: steps.daily-version.outputs.created id: changelog - uses: TriPSs/conventional-changelog-action@v3 + uses: loopwerk/tag-changelog@v1 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - skip-git-pull: "true" - output-file: "false" - fallback-version: "${{ steps.daily-version.outputs.version }}" - skip-version-file: "true" - git-message: "chore(release): {version}" - git-user-name: "${{ github.actor }}" - git-user-email: "${{ github.actor }}@users.noreply.github.com" + token: ${{ secrets.GITHUB_TOKEN }} + config_file: ./../.github/tag-changelog-config.js - name: Create release - if: env.DAILY_VERSION_CREATED - uses: actions/github-script@v6.4.1 + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - await github.request( - `POST /repos/${{ github.repository }}/releases`, - { - tag_name: "${{ steps.daily-version.outputs.version }}", - body: "${{ steps.daily-version.outputs.clean_changelog }}" - } - ); + tag_name: ${{ steps.daily-version.outputs.version }} + release_name: Release ${{ steps.daily-version.outputs.version }} + body: ${{ steps.changelog.outputs.changes }}