Skip to content

Commit

Permalink
Merge pull request #401 from 20001LastOrder/main
Browse files Browse the repository at this point in the history
Add workflow to publish PyPI package
  • Loading branch information
amirfz authored Jul 10, 2024
2 parents ffa7286 + 24702a1 commit 84b2821
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "PyPI Poetry Publish"

on:
release:
types: [ published ]

permissions:
contents: write

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

- name: Install poetry
run: pip install poetry poetry-core
shell: bash

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: poetry
check-latest: true

- name: Set GitHub Tag as Package Version
run: |
sed -i '0,/version =.*/s//version = "'"${{ github.event.release.tag_name }}"'"/' ./src/pyproject.toml
shell: bash

- name: Add and Commit Version
run: |
git add ./src/pyproject.toml
git config --global user.name "PyPI Poetry Publish Bot"
git config --global user.email "bot@ai.science"
git commit -m "Change version to ${{ github.event.release.tag_name }}" --allow-empty
git push origin HEAD:main
shell: bash

- name: Install dependencies
working-directory: ./src
run: |
poetry install --no-root
shell: bash

- name: Build and Publish
working-directory: ./src
run: |
poetry config pypi-token.pypi ${{secrets.pypi}}
poetry publish --build
shell: bash

0 comments on commit 84b2821

Please sign in to comment.