From 93dda9a578997a0ea8c8f778a5d3186d3b96aaa1 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Wed, 9 Jul 2025 21:28:18 +0200 Subject: [PATCH] chore(workflows): add CI workflows and configuration files - Add default merge message template for PRs - Introduce workflow for major version tag creation on release - Add workflow for auto changelog and release generation - Add git-cliff configuration for changelog formatting - Configure `.vscode` workspace settings and `.gitignore` updates --- .../default_merge_message/MERGE_TEMPLATE.md | 5 + .gitea/workflows/create-major-tag.yml | 61 ++++++++++ .gitea/workflows/release.yml | 19 ++++ .gitignore | 1 + .vscode/settings.json | 11 ++ README.md | 0 cliff.toml | 104 ++++++++++++++++++ 7 files changed, 201 insertions(+) create mode 100644 .gitea/default_merge_message/MERGE_TEMPLATE.md create mode 100644 .gitea/workflows/create-major-tag.yml create mode 100644 .gitea/workflows/release.yml create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 README.md create mode 100644 cliff.toml diff --git a/.gitea/default_merge_message/MERGE_TEMPLATE.md b/.gitea/default_merge_message/MERGE_TEMPLATE.md new file mode 100644 index 0000000..0d9c4f1 --- /dev/null +++ b/.gitea/default_merge_message/MERGE_TEMPLATE.md @@ -0,0 +1,5 @@ +chore(pr): ${PullRequestTitle} ${PullRequestReference} + +${PullRequestDescription} + +Merged from ${HeadBranch} into ${BaseBranch} diff --git a/.gitea/workflows/create-major-tag.yml b/.gitea/workflows/create-major-tag.yml new file mode 100644 index 0000000..fcdb7da --- /dev/null +++ b/.gitea/workflows/create-major-tag.yml @@ -0,0 +1,61 @@ +name: Create Major Version Tag + +on: + release: + types: [published] + +jobs: + update-major-tag: + runs-on: ubuntu-latest + permissions: + contents: write # required to delete/create tags + + steps: + # ▸ 1. Check out the repository at the release tag + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch all tags + ref: ${{ github.event.release.tag_name }} + + # ▸ 2. Extract the major version from the release tag + - name: Derive major version + id: derive + shell: bash + run: | + TAG="${{ github.event.release.tag_name }}" # e.g., v2.3.4 + echo "Release tag: $TAG" + + TAG_NOPREFIX="${TAG#v}" # remove leading v/V + MAJOR="${TAG_NOPREFIX%%.*}" # take part before the first dot + MAJOR_TAG="v${MAJOR}" # e.g., v2 + + echo "Major tag: $MAJOR_TAG" + echo "major_tag=$MAJOR_TAG" >>"$GITHUB_OUTPUT" + + # ▸ 3. Delete the old major tag (if it exists) and create a new one + - name: Re-create major tag + env: + MAJOR_TAG: ${{ steps.derive.outputs.major_tag }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + shell: bash + run: | + set -euo pipefail + + git config user.name "$CI_COMMIT_AUTHOR_NAME" + git config user.email "$CI_COMMIT_AUTHOR_EMAIL" + + # Determine the specific commit of the release tag + COMMIT_SHA="$(git rev-list -n 1 "$RELEASE_TAG")" + + echo "Commit of the release tag: $COMMIT_SHA" + + # (a) Locally and remotely remove the old major tag (if it exists) + git tag -d "$MAJOR_TAG" 2>/dev/null || true + git push --delete origin "$MAJOR_TAG" 2>/dev/null || true + + # (b) Create and push a new annotated tag + git tag -a "$MAJOR_TAG" "$COMMIT_SHA" \ + -m "Update $MAJOR_TAG → $RELEASE_TAG" + git push origin "$MAJOR_TAG" + + echo "✅ $MAJOR_TAG now points to $RELEASE_TAG ($COMMIT_SHA)" diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..7839072 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,19 @@ +name: Auto Changelog & Release + +on: + push: + branches: + - main + - "**" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Release + uses: https://git.0xmax42.io/actions/auto-changelog-release-action@v0 + with: + token: ${{ secrets.RELEASE_PUBLISH_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1453c54 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/*.env \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b0c3af9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#528859", + "activityBar.background": "#528859", + "activityBar.foreground": "#e7e7e7", + "activityBar.inactiveForeground": "#e7e7e799", + "activityBarBadge.background": "#c6c3db", + "activityBarBadge.foreground": "#15202b" + }, + "peacock.color": "#3f6844" +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..899c79c --- /dev/null +++ b/cliff.toml @@ -0,0 +1,104 @@ +# CLIFF_VERSION=2.8.0 +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. +[remote.gitea] +owner = "actions" +repo = "deb-changelog-action" + +[changelog] +# postprocessors +postprocessors = [ + { pattern = '', replace = "https://git.0xmax42.io" }, # replace gitea url +] + +# template for the changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{%- macro remote_url() -%} + /{{ remote.gitea.owner }}/{{ remote.gitea.repo }} +{%- endmacro -%} + +{% if version %}\ + {% if previous.version %}\ + ## [{{ version | trim_start_matches(pat="v") }}]\ + ({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }} + {% else %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {% endif %}\ +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }} - \ + ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\ + {% endfor %} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ + +""" +# remove the leading and trailing s +trim = true + +# render body even when there are no releases to process +# render_always = true +# output file path +# output = "test.md" + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + #{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, + # Check spelling of the commit with https://github.com/crate-ci/typos + # If the spelling is incorrect, it will be automatically fixed. + #{ pattern = '.*', replace_command = 'typos --write-changes -' }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "🚀 Features" }, + { message = "^fix", group = "🐛 Bug Fixes" }, + { message = "^doc", group = "📚 Documentation" }, + { message = "^perf", group = "⚡ Performance" }, + { message = "^refactor", group = "🚜 Refactor" }, + { message = "^style", group = "🎨 Styling" }, + { message = "^test", group = "🧪 Testing" }, + { message = "^chore\\(changelog\\)", skip = true }, + { message = "^chore\\(version\\)", skip = true }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci", group = "⚙️ Miscellaneous Tasks" }, + { body = ".*security", group = "🛡️ Security" }, + { message = "^revert", group = "◀️ Revert" }, + { message = ".*", group = "💼 Other" }, +] +# Regex to select git tags that represent releases. +tag_pattern = "v[0-9]+\\.[0-9]+\\.[0-9]+" +# filter out the commits that are not matched by commit parsers +filter_commits = false +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "newest"