diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81fabdf..e7c79e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,49 +1,118 @@ -name: publish_release -on: - push: - branches: [ "main" ] +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI + +on: push jobs: - release: - runs-on: ubuntu-latest + build: + name: Build distribution 📦 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: [3.9, 3.10.8, 3.11] + steps: - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install pypa/build + run: >- + python3 -m pip install build --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/ms-anomaly-detector # Replace with your PyPI project name + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 -# - name: Set up Python -# uses: actions/setup-python@v5 -# with: -# python-version: 3.11 + github-release: + name: >- + Sign the Python 🐍 distribution 📦 with Sigstore + and upload them to GitHub Release + needs: + - publish-to-pypi + runs-on: ubuntu-latest - - name: Build project - run: | - pip install Cython - pip install numpy - python setup.py sdist bdist_wheel + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore - - name: Create Draft Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 with: - # TODO - tag_name: 0.1.0 - release_name: 0.1.0 - draft: true - prerelease: false - - - name: Upload Release Asset - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + name: python-package-distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v1.2.3 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/anomaly_detector-0.1.0-cp310-cp310-linux_x86_64.whl - asset_name: anomaly_detector-0.1.0-cp310-cp310-linux_x86_64.whl - asset_content_type: application/whl - - - uses: eregon/publish-release@v1 + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' + + publish-to-testpypi: + name: Publish Python 🐍 distribution 📦 to TestPyPI + needs: + - build + runs-on: ubuntu-latest + + environment: + name: test-release + url: https://test.pypi.org/p/ms-anomaly-detector + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - release_id: ${{ steps.create_release.outputs.id }} \ No newline at end of file + repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6835ef7..a961549 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,9 +6,9 @@ name: CI on: # Triggers the workflow on push or pull request events but only for the "main" branch push: - branches: [ "main", "dev" ] + branches: ["main", "dev"] pull_request: - branches: [ "main", "dev" ] + branches: ["main", "dev"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -21,8 +21,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.9', '3.10.8', '3.11'] - + python-version: ["3.9", "3.10.8", "3.11"] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -36,14 +35,14 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{matrix.python-version}} - cache: 'poetry' + cache: "poetry" - name: install dependence working-directory: anomaly-detector run: | poetry env use ${{matrix.python-version}} poetry lock --no-update - poetry install + poetry install - name: compile .pyx file run: | @@ -67,7 +66,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.9', '3.10.8', '3.11'] + python-version: ["3.9", "3.10.8", "3.11"] steps: - uses: actions/checkout@v4 @@ -75,7 +74,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{matrix.python-version}} - cache: 'pip' + cache: "pip" - name: gen .whl file by setup run: | diff --git a/.gitignore b/.gitignore index b8a5e0b..44dfa13 100644 --- a/.gitignore +++ b/.gitignore @@ -403,7 +403,9 @@ model/ venv/ dist/ temp/ - +build/ +anomaly_detector.egg-info/ +anomaly-detector/anomaly_detector/univariate/_anomaly_kernel_cython.c .idea/ diff --git a/README.md b/README.md index c6e49e9..c9b093c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # Environment -python-version: '3.9', '3.10.8', '3.11' - +Tested on + +[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/) +[![Python 3.10](https://img.shields.io/badge/python-3.10.8-blue.svg)](https://www.python.org/downloads/release/python-3108/) +[![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3110/) + + # Getting Started ## Installing from pip diff --git a/setup.py b/setup.py index 04cfe74..6d55596 100644 --- a/setup.py +++ b/setup.py @@ -79,11 +79,8 @@ def run(self): version="0.1.0", license="MIT", description="Anomaly Detection", - # long_description=long_description, - # long_description_content_type="text/markdown", - # entry_points={"console_scripts": [""]}, author="test", - author_email="anomaly_detector@microsoft.com", + author_email="ad-oss@microsoft.com", url="https://github.com/microsoft/anomaly-detector", data_files=[ (".", ["README.md"]), @@ -97,6 +94,6 @@ def run(self): "Intended Audience :: Developers", "Topic :: Scientific/Engineering :: Artificial Intelligence", "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.9", ], )