Skip to content

Commit

Permalink
chore: migrate to python-semantic-release8 (#420)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck authored Aug 25, 2023
1 parent adf5a36 commit 0e35d88
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 35 deletions.
62 changes: 33 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
name: Release

on:
#push:
# branches: [ 'main' ]
push:
branches: [ 'main', 'master' ]
workflow_dispatch:
release_force:
# see https://python-semantic-release.readthedocs.io/en/latest/github-action.html#command-line-options
description: 'force release be one of: [major | minor | patch]'
type: choice
options:
- major
- minor
- patch
default: ""
required: false
prerelease_token:
description: 'The "prerelease identifier" to use as a prefix for the "prerelease" part of a semver. Like the rc in `1.2.0-rc.8`.'
type: choice
options:
- rc
- beta
- alpha
default: rc
required: false
prerelease:
description: "Is a pre-release"
type: boolean
default: false
required: false
inputs:
release_force:
# see https://python-semantic-release.readthedocs.io/en/latest/github-action.html#command-line-options
description: |
Force release be one of: [major | minor | patch]
Leave empty for auto-detect based on commit messages.
type: choice
options:
- "" # auto - no force
- major # force major
- minor # force minor
- patch # force patch
default: ""
required: false
prerelease_token:
description: 'The "prerelease identifier" to use as a prefix for the "prerelease" part of a semver. Like the rc in `1.2.0-rc.8`.'
type: choice
options:
- rc
- beta
- alpha
default: rc
required: false
prerelease:
description: "Is a pre-release"
type: boolean
default: false
required: false

concurrency:
group: deploy
Expand All @@ -41,9 +45,9 @@ jobs:
release:
# https://github.community/t/how-do-i-specify-job-dependency-running-in-another-workflow/16482
# limit this to being run on regular commits, not the commits that semantic-release will create
if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):')
# but also allow manual workflow dispatch
if: "!contains(github.event.head_commit.message, 'chore(release):')"
runs-on: ubuntu-latest
concurrency: release
permissions:
# NOTE: this enables trusted publishing.
# See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1#trusted-publishing
Expand Down Expand Up @@ -84,7 +88,7 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: ${{ github.event.inputs.release_force }}
prerelease: ${{ github.event.inputs.prerelease && "true" || "false" }}
prerelease: ${{ github.event.inputs.prerelease }}
prerelease_token: ${{ github.event.inputs.prerelease_token }}

- name: Publish package distributions to PyPI
Expand Down
22 changes: 16 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "cyclonedx-python-lib"
version = "4.0.1"
Expand Down Expand Up @@ -66,12 +70,18 @@ lxml = ">=4.7.0"
tox = "^3.2.8"
xmldiff = ">=2.4"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.semantic_release]
version_toml = ["pyproject.toml:tool.poetry.version"]
branch = "main"
# see https://python-semantic-release.readthedocs.io/en/latest/configuration.html
commit_message = "chore(release): {version}\n\nAutomatically generated by python-semantic-release"
upload_to_vcs_release = true
build_command = "pip install poetry && poetry build"
version_toml = ["pyproject.toml:tool.poetry.version"]
[tool.semantic_release.changelog]
changelog_file = "CHANGELOG.md"
exclude_commit_patterns = [
"chore\\(release\\):",
]
[tool.semantic_release.branches."alpha"]
match = "(feat|fix|tests|style|docs|chore)"
prerelease = true
prerelease_token = "alpha"

0 comments on commit 0e35d88

Please sign in to comment.