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

Refactor GitHub Actions workflow for release and tagging #46

Merged
merged 1 commit into from
Aug 22, 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
28 changes: 6 additions & 22 deletions .github/workflows/continuous_delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

jobs:
check_version:
check_version_and_publish:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -26,51 +26,35 @@ jobs:
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.poetry/bin:$PATH"

- name: Install project dependencies with Poetry
run: |
poetry install

- name: Style check
run: |
# run pre-commit hooks
poetry run pre-commit run --all-files

- name: Run tests
run: |
poetry run pytest -vv -k 'not time and not update_parallel'

- name: Extract version from pyproject.toml
id: extract_version
run: |
VERSION=$(poetry version -s)
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV

- name: Verify if version has changed
id: version_check
run: |
if [ $(git tag -l "v${{ env.PACKAGE_VERSION }}") ]; then
echo "Version ${{ env.PACKAGE_VERSION }} already exists."
exit 0
fi
- name: Generate output
run: echo "sVersionCheck=${{ steps.version_check.outcome }}" >> $GITHUB_OUTPUT

publish_and_tag:
needs: check_version
runs-on: ubuntu-latest
if: needs.check_version.outputs.sVersionCheck != 'failure'
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build and publish to pypi
uses: JRubics/[email protected]
with:
python_version: "3.8.1"
pypi_token: ${{ secrets.PYPI_TOKEN }}

if: ${{ success() && matrix.python-version == 3.8 }}
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish --build
- name: Create a Git tag
if: ${{ success() && matrix.python-version == 3.8 }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
Expand Down