Skip to content

Commit

Permalink
ci: Update python-semantic-release and add pre-release pipeline for d…
Browse files Browse the repository at this point in the history
…ev branch
  • Loading branch information
aiakide committed Jun 19, 2024
1 parent 485983b commit 16a28c1
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 26 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 🍦 Create Pre-Release

on:
pull_request:
branches:
- develop
types:
- closed
jobs:
release:
#if: ${{ github.event.pull_request.merged }}
name: 🏗️ Build package and publish to pypi
runs-on: ubuntu-latest
concurrency: release
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/niceml
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v3
with:
ref: 'develop'
fetch-depth: 0
token: ${{ secrets.RELEASE_WORKFLOW }}
- name: 🐍Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: 🔨 Setup poetry
uses: abatilo/[email protected]
with:
poetry-version: "1.7.1"
- name: 🔨Install dependencies
run: |
poetry config virtualenvs.create false
poetry install --no-interaction --no-ansi --with dev
- name: 🚀 Python Semantic Release
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.RELEASE_WORKFLOW }}
force: "prerelease"

- name: 🐍 Publish package distributions to PyPI
uses: pypa/[email protected]
if: steps.release.outputs.released == 'true'

- name: 🐙 Publish package distributions to GitHub Releases
uses: python-semantic-release/[email protected]
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.RELEASE_WORKFLOW }}
28 changes: 18 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
name: 🏗️ Build package and publish to pypi
runs-on: ubuntu-latest
concurrency: build
environment:
name: pypi
url: https://pypi.org/p/niceml
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v3
Expand All @@ -34,16 +37,21 @@ jobs:
run: |
poetry config virtualenvs.create false
poetry install --no-interaction --no-ansi --with dev
- name: 🍦 Release new version
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
cp -r configs template
semantic-release publish
env:
GH_TOKEN: ${{secrets.RELEASE_WORKFLOW}}
REPOSITORY_PASSWORD: ${{secrets.PYPI_TOKEN}}
REPOSITORY_USERNAME: __token__
- name: 🚀 Python Semantic Release
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.RELEASE_WORKFLOW }}

- name: 🐍 Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@v1
if: steps.release.outputs.released == 'true'

- name: 🐙 Publish package distributions to GitHub Releases
uses: python-semantic-release/[email protected]
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.RELEASE_WORKFLOW }}
documentation:
if: ${{ github.event.pull_request.merged }}
uses: ./.github/workflows/docs.yaml
77 changes: 61 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ visu = ["altair", "streamlit"]
[tool.poetry.group.dev.dependencies]
pytest = "^7.3.1"
pytest-cov = "^4.0.0"
python-semantic-release = "^7.33.3"
python-semantic-release = "^9.8.1"
pre-commit = "^3.3.1"
black = "^24.0.0"
mkdocs-material = "^9.1.9"
Expand All @@ -109,25 +109,70 @@ line-length = 100
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.poetry.scripts]
niceml = 'niceml.cli.climain:program.run'

[tool.semantic_release]
assets = []
build_command = "poetry build"
build_command_env = []
version_variable = [
"niceml/__init__.py:__version__",
"pyproject.toml:tool.poetry.version"
]
version_toml = [
"pyproject.toml:tool.poetry.version"
]

version_source="tag"
commit_version_number = true
commit_message = "{version}\n\nAutomatically generated by python-semantic-release"
commit_parser = "angular"
logging_use_named_masks = false
major_on_zero = false
branch = "main"
upload_to_PyPI = true
upload_to_release = true
build_command = "poetry build"
repository = "pypi"
commit_subject="New release with version {version}"
commit_author="github-actions <[email protected]>"
allow_zero_version = true
no_git_verify = false
tag_format = "v{version}"

[tool.poetry.scripts]
niceml = 'niceml.cli.climain:program.run'
[tool.semantic_release.branches.main]
match = "main"
prerelease = false

[tool.semantic_release.branches.develop]
match = "develop"
prerelease_token = "dev"
prerelease = true

[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 = "github-actions <[email protected]>"

[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

0 comments on commit 16a28c1

Please sign in to comment.