Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 Add automated release process workflow #7

Merged
merged 1 commit into from
Mar 11, 2024
Merged
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
59 changes: 59 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Automated Release Process

on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -

- name: Test
run: |
poetry install
poetry run pytest

- name: Determine Version Change
id: version_check
run: |
VERSION="v$(poetry version -s)"
echo "Current version: $VERSION"

LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name')
echo "Latest release version: $LATEST_RELEASE"

if [ "$VERSION" != "$LATEST_RELEASE" ]; then
echo "Version has changed."
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "new_version=$VERSION" >> $GITHUB_OUTPUT
else
echo "No version change detected."
echo "version_changed=false" >> $GITHUB_OUTPUT
fi

- name: Create Release
if: steps.version_check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version_check.outputs.new_version }}
generate_release_notes: True

- name: Build and publish to PyPI
if: steps.version_check.outputs.version_changed == 'true'
run: |
poetry build
poetry publish