diff --git a/.github/workflows/build_python_package.yml b/.github/workflows/build_python_package.yml new file mode 100644 index 0000000..02de702 --- /dev/null +++ b/.github/workflows/build_python_package.yml @@ -0,0 +1,104 @@ +name: Publish Python 🐍 distribution 📦 to PyPI and run tests + + +on: + workflow_dispatch: + + release: + types: [created] + + +jobs: + build: + if: github.repository == 'CaffeineCrew/Techdocs' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + + - name: Install package-dependencies + - run: | + python -m pip install --upgrade pip + pip install setuptools wheel + + - name: build package + - run: | + python python setup.py sdist bdist_wheel + - name: Store dist as an artifact + - uses: actions/upload-artifact@v3 + - with: + name: python-package + path: dist/ + + + publish_package_to_testpypi: + if: github.repository == 'CaffeineCrew/Techdocs' + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install twine + + - name: Publish 📦 to testpypi + env: + TESETPYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + TESTPYPI_CLI: ${{ secrets.PYPI_PASSWORD }} + - uses: actions/download-artifact@v3 + - with: + name: python-package + - run: | + twine upload -r testpypi dist/* + + + run_tests: + needs: [build, publish_package_to_testpypi] + runs-on: ubuntu-latest + steps: + - working-directory: /techdocs + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --no-cache-dir --index-url https://test.pypi.org/simple/ --extra-index-url=https://pypi.org/simple/ techdocs + + - name: Test testpypi package + run: | + techdocs run tests + + + publish_package_to_pypi: + needs: [build, publish_package_to_testpypi, run_tests] + if: github.repository == 'CaffeineCrew/Techdocs' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + + - name: Publish 📦 to pypi + env: + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_CLI: ${{ secrets.PYPI_PASSWORD }} + - uses: actions/download-artifact@v3 + - with: + name: python-package + - run: | + twine upload dist/* + pip install techdocs --upgrade +