Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 18 additions & 46 deletions .github/workflows/release-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine python-semantic-release setuptools-scm
pip install build twine python-semantic-release>=9.0.0 setuptools-scm

- name: Create release branch
run: |
Expand All @@ -37,14 +37,19 @@ jobs:
git checkout -b release-main
git push --set-upstream origin release-main

- name: Run semantic-release
- name: Run semantic-release version on release-main branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Set the branch via environment variable
SEMANTIC_RELEASE_BRANCH: release-main
run: |
semantic-release version
semantic-release publish
semantic-release --verbose version

# For semantic-release 9.x, the publish command needs to be run separately
- name: Run semantic-release publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
semantic-release --verbose publish

- name: Push release branch
run: git push origin release-main
Expand All @@ -59,46 +64,13 @@ jobs:
--title "Automated Release Updates" \
--body "This pull request contains updates from the semantic-release process." || true

- name: Build package
run: python -m build

- name: Publish package to PyPI
# This is only needed if semantic-release publish didn't handle the PyPI upload
- name: Build and publish package to PyPI if needed
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
# create-pr-back-to-master:
# needs: release
# runs-on: ubuntu-latest
# permissions:
# contents: write
# pull-requests: write
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# ref: main

# - name: Set Git Identity
# run: |
# git config --global user.name 'GitHub Actions'
# git config --global user.email 'github-actions@github.com'

# - name: Create Pull Request from main to master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# git fetch origin master:refs/remotes/origin/master
# DIFF_COUNT=$(git rev-list --count origin/master..HEAD)
# if [ "$DIFF_COUNT" -gt 0 ]; then
# echo "Differences found between main and master. Creating PR..."
# gh pr create \
# --base master \
# --head main \
# --title "Sync master with main after release" \
# --body "This is an automated PR to sync changes from main back to master after a release." || true
# echo "Pull request created or already exists."
# else
# echo "No differences found between main and master. Skipping PR creation."
# fi
run: |
if [ ! -f "dist/*" ]; then
python -m build
twine upload dist/*
fi
24 changes: 16 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=6.0"]
build-backend = "setuptools.build_meta"
Expand All @@ -9,16 +8,25 @@ local_scheme = "no-local-version"

[tool.semantic_release]
version_source = "tag"
upload_to_pypi = true
commit = false
push = false
upload_to_pypi = true
build_command = "python -m build"

[tool.semantic_release.release_groups]
default = { branches = ["release-main"] }
# This is the key configuration for version 9.x
[tool.semantic_release.branches.release-main]
match = "release-main"
prerelease = false

# The following configurations are optional but recommended
[tool.semantic_release.publish]
repository = "pypi"
upload_to_release = true
upload_to_pypi = true
dist_glob_patterns = ["dist/*"]

[tool.semantic_release.remote.token]
env = "GH_TOKEN"

[tool.semantic_release.options]
patch_without_tag = false
allowed_tags = "(a|alpha|b|beta|rc)"
[tool.semantic_release.remote]
type = "github"
ignore_token_for_push = false