Skip to content

Commit

Permalink
ci: Add release and pre-release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
aiakide committed Jan 30, 2025
1 parent c9d1668 commit fd69425
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 2 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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/ligthml
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: 🐍Setup Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: 🧙‍♂️Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: 🔨Install dependencies
run: uv sync --all-extras --dev
- name: ⬇️ Download current coverage report
uses: actions/download-artifact@v4
with:
name: code-coverage
path: ./coverage.xml
- name: 📃Pytest coverage report
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
hide-comment: true
pytest-xml-coverage-path: ./coverage.xml

- name: ✏️ Update Readme with Coverage Badge
run: |
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
- name: 🚀 Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v9
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: "prerelease"

- name: 🐍 Publish package distributions to PyPI
if: steps.release.outputs.released == 'true'
run: uv publish

- name: 🐙 Publish package distributions to GitHub Releases
uses: python-semantic-release/publish-action@9
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.10" ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.10", "3.11", "3.12","3.13", "3.14" ]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
name: 🧪 Run pytests wit ${{matrix.python-version}} on ${{matrix.os}}
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 📦 Create Release

on:
pull_request:
branches:
- main
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/ligthml
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v4
with:
ref: 'main'
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: 🐍Setup Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: 🧙‍♂️Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: 🔨Install dependencies
run: uv sync --all-extras --dev
- name: ⬇️ Download current coverage report
uses: actions/download-artifact@v4
with:
name: code-coverage
path: ./coverage.xml
- name: 📃Pytest coverage report
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
hide-comment: true
pytest-xml-coverage-path: ./coverage.xml

- name: ✏️ Update Readme with Coverage Badge
run: |
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
- name: 🚀 Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v9
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: 🐍 Publish package distributions to PyPI
if: steps.release.outputs.released == 'true'
run: uv publish

- name: 🐙 Publish package distributions to GitHub Releases
uses: python-semantic-release/publish-action@9
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit fd69425

Please sign in to comment.