From 4d6a1bb649bded14ece02ddb64afd768f2d4ce25 Mon Sep 17 00:00:00 2001 From: Dadmehr <134191240+BDadmehr0@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:39:52 +0000 Subject: [PATCH] Create publish.yml --- .github/workflows/publish.yml | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..dac4437 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,54 @@ +name: Build and Publish + +on: + push: + branches: + - main + - "release-*" + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest + + - name: Run tests + run: pytest tests/ + + publish: + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-') + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Build package + run: | + python -m pip install --upgrade pip setuptools wheel + python setup.py sdist bdist_wheel + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1.9.1 + with: + password: ${{ secrets.PYPI_API_TOKEN }}