Skip to content

Commit

Permalink
ci: set up the package CD pipeline (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
paduszyk committed May 23, 2024
1 parent 5f08ec8 commit 9676813
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pre-commit-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

jobs:
pre-commit-run:
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
name: Run Pre-commit hooks
runs-on: ubuntu-latest
steps:
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/python-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Python: CD"

on:
push:
tags:
- "*.*.*"

jobs:
build:
name: Build package
runs-on: ubuntu-latest
outputs:
package-version: ${{ steps.package-version.outputs.package-version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
- run: python -m pip install --upgrade pip
- run: python -m pip install build
- run: python -m build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*
- id: package-version
run: |
python -m pip install .
echo "package-version=$(
python -c 'import sys, xlsx_serializer; sys.stdout.write(xlsx_serializer.__version__)'
)" >> $GITHUB_OUTPUT
check-tag:
name: Check tag
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
if [ "${{ needs.build.outputs.package-version }}" != "${{ github.ref_name }}" ]; then
exit 1
fi
pypi:
name: Publish package to PyPI
needs:
- check-tag
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: PyPI
url: https://pypi.org/p/django-xlsx-serializer/
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
release:
name: Create GitHub release
needs:
- pypi
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
2 changes: 2 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

jobs:
get-python-versions:
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
name: Get Python versions
runs-on: ubuntu-latest
outputs:
Expand All @@ -23,6 +24,7 @@ jobs:
echo "$(python ./scripts/get_python_versions.py)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
format-nox-sessions:
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
name: Format Nox sessions
runs-on: ubuntu-latest
outputs:
Expand Down

0 comments on commit 9676813

Please sign in to comment.