diff --git a/.github/workflows/python-ci-tests.yml b/.github/workflows/python-ci-tests.yml index 47f860e1..7ecbedb1 100644 --- a/.github/workflows/python-ci-tests.yml +++ b/.github/workflows/python-ci-tests.yml @@ -4,12 +4,12 @@ name: cti-python-stix2 test harness on: [push, pull_request] jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12'] name: Python ${{ matrix.python-version }} Build steps: @@ -32,3 +32,24 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: false # optional (default = false) verbose: true # optional (default = false) + + publish-to-test-pypi: + runs-on: ubuntu-latest + needs: test + + permissions: + id-token: write + + steps: + - name: Download dist files + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Publish to Test PyPI + if: ${{ github.event_name == 'push' }} + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true + repository-url: https://test.pypi.org/legacy/ diff --git a/setup.py b/setup.py index d0d8fe77..4dfdf8b5 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,8 @@ #!/usr/bin/env python from codecs import open import os.path +import sys +import pkg_resources from setuptools import find_packages, setup @@ -22,6 +24,14 @@ def get_long_description(): return f.read() + +try: + pkg_resources.get_distribution("stix2") + sys.exit(f"Error: 'stix2' is installed. Uninstall it before proceeding.") +except pkg_resources.DistributionNotFound: + pass + + setup( name='misp-lib-stix2', version=get_version(),