From b2bede68b967915761c22139675257e630a40400 Mon Sep 17 00:00:00 2001 From: dylanljones Date: Wed, 16 Mar 2022 11:06:09 +0100 Subject: [PATCH] ci: add GitHub workflows --- .github/workflows/pypi-test-publish.yml | 51 +++++++++++++++++++++++++ .github/workflows/test_versioning.yml | 36 +++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 .github/workflows/pypi-test-publish.yml create mode 100644 .github/workflows/test_versioning.yml diff --git a/.github/workflows/pypi-test-publish.yml b/.github/workflows/pypi-test-publish.yml new file mode 100644 index 0000000..c2d4d74 --- /dev/null +++ b/.github/workflows/pypi-test-publish.yml @@ -0,0 +1,51 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + + +name: Upload Python Package to TestPyPi + +on: + # Triggers the workflow when a release is created + release: + types: [published] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build-n-publish: + name: Build and publish Python Package to TestPyPi + runs-on: ubuntu-latest + + steps: + - name: get latest release with tag + id: latestrelease + run: | + echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/dylanljones/cmpy/releases/latest --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq '.tag_name' | sed 's/\"//g')" + + - name: confirm release tag + run: | + echo ${{ steps.latestrelease.outputs.releasetag }} + + - name: checkout + uses: actions/checkout@v2 + with: + ref: ${{ steps.latestrelease.outputs.releasetag }} + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install twine + pip install .[build] + + - name: Build and publish distribution 📦 to Test PyPI + env: + TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload --repository testpypi dist/* diff --git a/.github/workflows/test_versioning.yml b/.github/workflows/test_versioning.yml new file mode 100644 index 0000000..1eb5ff2 --- /dev/null +++ b/.github/workflows/test_versioning.yml @@ -0,0 +1,36 @@ +name: Test Installation + +on: + push: + branches: [master, dev] + workflow_dispatch: + +jobs: + + build: + name: Build and install + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + python-version: ["3.10"] + other-os: [false] + + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.other-os }} # don't cancel due to OS specific failures + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Build and install + run: | + python -m pip install --upgrade pip + pip install . + - name: Get package version + run: python setup.py --version