From 4c3992619bbb92b4424d259aa2eea08aa96e0074 Mon Sep 17 00:00:00 2001 From: "Alexandre Teles (afterSt0rm)" <1757773+alexandreteles@users.noreply.github.com> Date: Thu, 12 Sep 2024 23:12:02 -0300 Subject: [PATCH] feat(ci): add gh actions worfklow files (#7) * feat(ci): add gh actions worfklow files * fix(ci): try to fix detached head * fix(ci): fix wrong branch * fix(ci): rebase from origin * fix(ci): add dummy git user --- .github/workflows/pull_requests.yml | 38 ++++++++++++++++++ .github/workflows/release.yml | 31 +++++++++++++++ pyproject.toml | 60 ++++++++++++++++++++++++++++- 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pull_requests.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml new file mode 100644 index 0000000..809ee0d --- /dev/null +++ b/.github/workflows/pull_requests.yml @@ -0,0 +1,38 @@ +name: Python Package Release Test +on: + pull_request: + types: [opened, synchronize, reopened, edited] +jobs: + test-release: + runs-on: ubuntu-latest + concurrency: release + permissions: + contents: write + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup dummy git user + run: | + git config --global user.email "action@github.com" + git config --global user.name "GitHub Action" + - name: Checkout main and rebase + run: | + git checkout main + git rebase origin/${{ github.head_ref }} + - name: Install poetry + run: pipx install poetry + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + cache: 'poetry' + - name: Install dependencies + run: poetry install + - name: Python Semantic Release + uses: python-semantic-release/python-semantic-release@v9.8.8 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + root_options: "-vv --noop" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..98fabf8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Python Package Release +on: + push: + branches: + - main +jobs: + release: + runs-on: ubuntu-latest + concurrency: release + permissions: + contents: write + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install poetry + run: pipx install poetry + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + cache: 'poetry' + - name: Install dependencies + run: poetry install + - name: Python Semantic Release + uses: python-semantic-release/python-semantic-release@v9.8.8 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 3233356..add0401 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,4 +23,62 @@ pdoc3 = "^0.11.1" [build-system] requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" \ No newline at end of file +build-backend = "poetry.core.masonry.api" + +[tool.semantic_release] +version_toml = [ + "pyproject.toml:tool.poetry.version", +] +build_command = "poetry build" +commit_message = "{version}\n\nAutomatically generated by python-semantic-release" +commit_parser = "angular" +logging_use_named_masks = false +major_on_zero = true +allow_zero_version = true +no_git_verify = false +tag_format = "v{version}" + +[tool.semantic_release.branches.main] +match = "(main|master)" +prerelease_token = "rc" +prerelease = false + +[tool.semantic_release.changelog] +template_dir = "templates" +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 +insecure = false + +[tool.semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true +