Merge pull request #16 from jbsparrow/jbsparrow-patch-1 #10
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
name: Publish To PyPi | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*.*.*' | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11.4 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11.4" | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python - -y | |
- name: Check Version | |
id: check-version | |
run: | | |
version=$(poetry version --short) | |
if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "version=$version" >> $GITHUB_STATE | |
else | |
echo "Not a valid version bump. Skipping tag creation." | |
exit 0 | |
fi | |
- name: Create Tag | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && env.version != '' }} | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git tag ${{ env.version }} | |
git push origin ${{ env.version }} | |
release: | |
runs-on: ubuntu-latest | |
needs: check-version | |
if: ${{ needs.check-version.outputs.version != '' }} | |
steps: | |
- name: Retrieve Version | |
run: echo "VERSION=${{ needs.check-version.outputs.version }}" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11.4 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11.4" | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python - -y | |
- name: Update PATH | |
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Build project for distribution | |
run: poetry build | |
- name: Publish to PyPI | |
env: | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} | |
run: poetry publish |