fix: ipc output issue #17
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 Python Package | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
types: | |
- opened | |
env: | |
PACKAGE_NAME: crawlab-sdk | |
jobs: | |
build: | |
name: Build package | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.build.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
poetry install | |
- name: Build package | |
id: build | |
run: | | |
poetry build | |
echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT | |
- name: Run tests | |
run: | | |
python -m pytest tests/ | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
check_version: | |
name: Check version | |
needs: build | |
runs-on: ubuntu-latest | |
outputs: | |
is_new_version: ${{ steps.check.outputs.is_new_version }} | |
steps: | |
- name: Check package version | |
id: check | |
run: | | |
version="${{ needs.build.outputs.version }}" | |
status_code=$(curl -o /dev/null -s -w "%{http_code}" https://pypi.org/project/${{ env.PACKAGE_NAME }}/${version}/) | |
echo "status_code=${status_code}" | |
if [ "$status_code" = "200" ]; then | |
is_new_version=false | |
else | |
is_new_version=true | |
fi | |
echo "is_new_version=${is_new_version}" >> $GITHUB_OUTPUT | |
publish: | |
name: Publish to PyPI | |
needs: [build, check_version] | |
runs-on: ubuntu-latest | |
environment: pypi | |
permissions: | |
id-token: write | |
if: needs.check_version.outputs.is_new_version == 'true' | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@release/v1 |