modified: get_current_date_time tool #48
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: Python Package CI/CD | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
poetry add pytest | |
poetry install | |
- name: Test with pytest | |
run: poetry run pytest tests/ | |
- name: Debug | |
run: | | |
echo "Event name: ${{ github.event_name }}" | |
echo "Pull Request base ref: ${{ github.event.pull_request.base.ref }}" | |
echo "Pull Request merged: ${{ github.event.pull_request.merged }}" | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
if: | | |
github.event_name == 'pull_request' && | |
github.event.pull_request.base.ref == 'main' && | |
github.event.pull_request.merged == true || | |
github.event_name == 'push' && | |
github.event.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
pip install twine | |
poetry install | |
- name: Build and upload to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
echo "Building and uploading to PyPI" | |
echo "TWINE_USERNAME: $TWINE_USERNAME" | |
poetry build | |
twine upload dist/* --verbose | |
echo "Uploaded to pypi" |