From b50a4d452482d9e268ea3404055463db79409731 Mon Sep 17 00:00:00 2001 From: guanhuaw Date: Sun, 4 Aug 2024 15:27:02 -0700 Subject: [PATCH] semantic release --- .github/workflows/python-release.yml | 51 ++++++++++++++++++++++------ pyproject.toml | 7 ++-- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index 07c06f1..ce3b846 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -1,26 +1,57 @@ name: Semantic Release on: + push: + branches: + - master pull_request: branches: - master - workflow_dispatch: jobs: release: + name: Semantic Release runs-on: ubuntu-latest concurrency: release permissions: - id-token: write contents: write + issues: write + pull-requests: write + id-token: write steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Python Semantic Release - uses: python-semantic-release/python-semantic-release@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install python-semantic-release build + + - name: Install project dependencies + run: | + pip install -e . + # or if you use poetry: + # pip install poetry && poetry install + + - name: Semantic Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + semantic-release publish + + - name: Python Semantic Release + uses: python-semantic-release/python-semantic-release + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index bdf0deb..71c34b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,9 @@ exclude = [ "venv", ".git", ] + [tool.semantic_release] -version_variables = ["setup.py:__version__"] -upload_to_pypi = true +version_variable = ["pyproject.toml:project.version"] +branch = "master" +upload_to_pypi = false +build_command = "python -m build"