-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feature: implement semantic release workflow and update versioning
- Loading branch information
Showing
6 changed files
with
263 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- feature/gh-actions # Trigger on push to this branch | ||
pull_request: | ||
branches: | ||
- main # Trigger on PR merge to main | ||
|
||
concurrency: | ||
group: release | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Configure Git User | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "actions@github.com" | ||
- name: Install Dependencies | ||
run: | | ||
pip install python-semantic-release setuptools_scm | ||
- name: Run Semantic Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PYTHON_TOKEN: ${{ secrets.PYPI_TOKEN }} # Optional if uploading to PyPI | ||
run: semantic-release publish | ||
|
||
- name: Force Push Updated Tag (if required) | ||
if: ${{ github.ref_name == 'feature/semantic-release' }} | ||
run: | | ||
latest_tag=$(git describe --tags --abbrev=0) | ||
git tag -f "$latest_tag" | ||
git push origin --tags --force | ||
sync-dev: | ||
needs: release | ||
if: ${{ github.ref_name == 'main' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure Git User | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "actions@github.com" | ||
- name: Sync Dev Branch | ||
run: | | ||
git fetch origin | ||
git checkout dev | ||
git merge origin/main --no-edit | ||
git push origin dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from subprocess import run | ||
|
||
|
||
def post_version(version: str): | ||
""" | ||
Hook to update the version file, commit the changes, and force push the new tag. | ||
This hook uses the Gitmoji specification for commit messages. | ||
""" | ||
# Update the version file using uv build | ||
run(["uv", "build", "--frozen"], check=True) | ||
|
||
# Commit the updated version file | ||
run(["git", "add", "aymurai/version.py"], check=True) | ||
run(["git", "commit", "-m", f"🔖 chore: update version to {version}"], check=True) | ||
run(["git", "push"], check=True) | ||
|
||
# Update and force-push the Git tag | ||
tag_name = f"v{version}" | ||
run(["git", "tag", "-f", tag_name], check=True) | ||
run(["git", "push", "--force", "origin", tag_name], check=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.