Skip to content

Commit

Permalink
Refactor GitHub Actions workflow for release and tagging (#46)
Browse files Browse the repository at this point in the history
Change log:
 1. Refactor CD config to avoid github actions for publishing, and use a single conditional job.
  • Loading branch information
shaharbar1 authored Aug 22, 2024
1 parent 8930cf9 commit 9e7f01f
Showing 1 changed file with 6 additions and 22 deletions.
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

0 comments on commit 9e7f01f

Please sign in to comment.