From 4de77010a108dc055ccd3c1cbd3ba1cf5dbc78a3 Mon Sep 17 00:00:00 2001 From: Furkan Pehlivan <65170388+pehlicd@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:16:23 +0200 Subject: [PATCH] feat(ci): add semantic version releasing mechanism (#1039) Co-authored-by: Keep Release Bot Co-authored-by: Shahar Glazner --- .github/workflows/release.yml | 27 ++++++++++++++++ .gitignore | 2 ++ CHANGELOG.md | 25 +++++++++++++++ pyproject.toml | 58 +++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 CHANGELOG.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..160177854 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Keep Release + +on: + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + concurrency: release + permissions: + id-token: write + contents: write + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Release Keep + uses: python-semantic-release/python-semantic-release@v9.4.0 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + git_committer_name: Keep Release Bot + git_committer_email: no-reply@keephq.dev + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index b092ab815..8f17846ff 100644 --- a/.gitignore +++ b/.gitignore @@ -172,8 +172,10 @@ keep.yaml providers.yaml .vercel keepstate.json + # keep single tenant id e1faa321-35df-486b-8fa8-3601ee714011* + # sqlite db *.sqlite3 state/* diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..a53da963a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# CHANGELOG +{% if context.history.unreleased | length > 0 %} + +{# UNRELEASED #} +## Unreleased +{% for type_, commits in context.history.unreleased | dictsort %} +### {{ type_ | capitalize }} +{% for commit in commits %}{% if type_ != "unknown" %} +* {{ commit.commit.message.rstrip() }} ([`{{ commit.commit.hexsha[:7] }}`]({{ commit.commit.hexsha | commit_hash_url }})) +{% else %} +* {{ commit.commit.message.rstrip() }} ([`{{ commit.commit.hexsha[:7] }}`]({{ commit.commit.hexsha | commit_hash_url }})) +{% endif %}{% endfor %}{% endfor %} + +{% endif %} + +{# RELEASED #} +{% for version, release in context.history.released.items() %} +## {{ version.as_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }}) +{% for type_, commits in release["elements"] | dictsort %} +### {{ type_ | capitalize }} +{% for commit in commits %}{% if type_ != "unknown" %} +* {{ commit.commit.message.rstrip() }} ([`{{ commit.commit.hexsha[:7] }}`]({{ commit.commit.hexsha | commit_hash_url }})) +{% else %} +* {{ commit.commit.message.rstrip() }} ([`{{ commit.commit.hexsha[:7] }}`]({{ commit.commit.hexsha | commit_hash_url }})) +{% endif %}{% endfor %}{% endfor %}{% endfor %} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 2932d4c59..4487e4993 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,3 +104,61 @@ keep = "keep.cli.cli:cli" [tool.ruff.lint] ignore = ["F405", "F811", "E712", "E711", "F403"] + +[tool.semantic_release] +assets = [] +commit_message = "{version}\n\n Released new version of the Keep" +commit_parser = "angular" +logging_use_named_masks = false +major_on_zero = true +allow_zero_version = true +tag_format = "v{version}" +version_toml = [ + "pyproject.toml:tool.poetry.version", +] + +[tool.semantic_release.branches.main] +match = "(main|master)" +prerelease_token = "rc" +prerelease = false + +[tool.semantic_release.changelog] +template_dir = "./" +changelog_file = "CHANGELOG.md" +exclude_commit_patterns = [] + +[tool.semantic_release.changelog.environment] +block_start_string = "{%" +block_end_string = "%}" +variable_start_string = "{{" +variable_end_string = "}}" +comment_start_string = "{#" +comment_end_string = "#}" +trim_blocks = false +lstrip_blocks = false +newline_sequence = "\n" +keep_trailing_newline = false +extensions = [] +autoescape = true + +[tool.semantic_release.commit_author] +env = "GIT_COMMIT_AUTHOR" +default = "semantic-release " + +[tool.semantic_release.commit_parser_options] +allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"] +minor_tags = ["feat"] +patch_tags = ["fix", "perf"] +default_bump_level = 0 + +[tool.semantic_release.remote] +name = "origin" +type = "github" +ignore_token_for_push = false + +[tool.semantic_release.remote.token] +env = "GH_TOKEN" + +[tool.semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true