From 565ec814abf6ac96614dfc268c8b20eded135994 Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Tue, 11 Jun 2024 16:13:17 +0800 Subject: [PATCH 1/2] refactor: Use recently updated release action The previous action worked extremely well, but has long since been archived and no longer updated. The replacement worked in a similar manner, but based release notes off labels and not commits. So commit changelog generation has also been added --- .NOTES.jinja | 36 ++++++++++++++++++++++++++++ .git-changelog.toml | 4 ++++ .github/workflows/release-cally.yaml | 21 ++++++++++++---- .gitignore | 3 +++ 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 .NOTES.jinja create mode 100644 .git-changelog.toml diff --git a/.NOTES.jinja b/.NOTES.jinja new file mode 100644 index 0000000..c43ceeb --- /dev/null +++ b/.NOTES.jinja @@ -0,0 +1,36 @@ +{#- macro: render_commit -#} +{%- macro render_commit(commit) -%} +- {{ commit.convention.subject|default(commit.subject) }} ([{{ commit.hash|truncate(7, True, '') }}]({{ commit.url }}) by {{ commit.author_name }}). +{%- if commit.text_refs.issues_not_in_subject %} Related issues/PRs: {% for issue in commit.text_refs.issues_not_in_subject -%} +{% if issue.url %}[{{ issue.ref }}]({{ issue.url }}){% else %}{{ issue.ref }}{% endif %}{% if not loop.last %}, {% endif -%} +{%- endfor -%}{%- endif -%} +{%- for trailer_name, trailer_value in commit.trailers.items() -%} +{%- if trailer_value|is_url %} [{{ trailer_name }}]({{ trailer_value }}) +{%- else %} {{ trailer_name }}: {{ trailer_value }}{% endif %} +{%- if not loop.last %},{% endif %} +{%- endfor -%} +{%- endmacro -%} + +{#- macro: render_section -#} +{%- macro render_section(section) -%} +### {{ section.type or "Misc" }} + +{% for commit in section.commits|sort(attribute='author_date',reverse=true)|unique(attribute='subject') -%} +{{ render_commit(commit) }} +{% endfor %} +{%- endmacro -%} + +{%- macro render_version(version) -%} +{% for type in changelog.sections %} +{%- if type in version.sections_dict %} +{%- with section = version.sections_dict[type] %} +{{ render_section(section) }} +{%- endwith %} +{%- endif %} +{%- endfor %} +{% endmacro -%} + +{#- template -#} +{% for version in changelog.versions_list -%} +{{ render_version(version) }} +{%- endfor -%} diff --git a/.git-changelog.toml b/.git-changelog.toml new file mode 100644 index 0000000..504fdf4 --- /dev/null +++ b/.git-changelog.toml @@ -0,0 +1,4 @@ +convention = "conventional" +output = "NOTES.md" +template = "path:.NOTES.jinja" +sections = "feat,fix,docs,style,refactor,perf,test" diff --git a/.github/workflows/release-cally.yaml b/.github/workflows/release-cally.yaml index 7134c7f..6450854 100644 --- a/.github/workflows/release-cally.yaml +++ b/.github/workflows/release-cally.yaml @@ -61,16 +61,29 @@ jobs: runs-on: ubuntu-latest needs: build-artifact steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install git-changelog + run: pip install git-changelog + - name: Prepare release notes + run: | + PREVIOUS=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1)) + git-changelog --filter-commits ${PREVIOUS}..v${{ needs.build-artifact.outputs.version }} - name: Get distribution uses: actions/download-artifact@v3 with: name: package-${{ needs.build-artifact.outputs.version }} path: dist - - uses: "marvinpinto/action-automatic-releases@latest" + - name: Release + uses: softprops/action-gh-release@v2 with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false - draft: false + body_path: NOTES.md files: | dist/cally-${{ needs.build-artifact.outputs.version }}.tar.gz diff --git a/.gitignore b/.gitignore index 68bc17f..fe9f6cf 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# Releasing +NOTES.md From c3ad6ba9063958ba5bb2a03dbb582e00253896f9 Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Tue, 11 Jun 2024 16:16:12 +0800 Subject: [PATCH 2/2] chore: Update Artifact Actions v3 uses the deprecated node version, this updates it to the most recent version --- .github/workflows/build-tool-cache.yaml | 2 +- .github/workflows/release-cally.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-tool-cache.yaml b/.github/workflows/build-tool-cache.yaml index 1b3f925..6a2864d 100644 --- a/.github/workflows/build-tool-cache.yaml +++ b/.github/workflows/build-tool-cache.yaml @@ -24,7 +24,7 @@ jobs: with: python-version: ${{ matrix.python }} - name: Get distribution - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: package-${{ inputs.version }} path: dist diff --git a/.github/workflows/release-cally.yaml b/.github/workflows/release-cally.yaml index 6450854..3e663c6 100644 --- a/.github/workflows/release-cally.yaml +++ b/.github/workflows/release-cally.yaml @@ -34,7 +34,7 @@ jobs: - name: Build distribution run: python -m build - name: Save dist files - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: package-${{ steps.set-version.outputs.version }} path: dist @@ -50,7 +50,7 @@ jobs: id-token: write steps: - name: Get distribution - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: package-${{ needs.build-artifact.outputs.version }} path: dist @@ -76,7 +76,7 @@ jobs: PREVIOUS=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1)) git-changelog --filter-commits ${PREVIOUS}..v${{ needs.build-artifact.outputs.version }} - name: Get distribution - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: package-${{ needs.build-artifact.outputs.version }} path: dist