From 17e8d1837b6c828c3fa37f836c0e1e0c70133f3f Mon Sep 17 00:00:00 2001 From: Songki Choi Date: Thu, 13 Jun 2024 15:56:47 +0900 Subject: [PATCH] Add PyPI publish workflow (#15) --- .github/workflows/publish.yml | 71 +++++++++++++++++++++++++++++++++++ pyproject.toml | 4 +- 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..f548b010 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,71 @@ +name: Publish to PyPI + +on: + workflow_dispatch: # run on request (no need for PR) + push: + tags: + - '*' + +# Declare default permissions as read only. +permissions: read-all + +jobs: + Build-Packages: + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Set up Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: "3.10" + - name: Install pypa/build + run: python -m pip install --require-hashes --no-deps -r .ci/requirements/publish/requirements.txt + - name: Build packages + run: python -m build + - name: Upload artifacts + uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 + with: + name: packages + path: dist/* + + Publish-Packages: + needs: Build-Packages + environment: pypi + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + id-token: write + steps: + - name: Download artifacts + uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 + with: + path: dist + pattern: packages* + merge-multiple: true + # Determine where to publish the package distribution to PyPI or TestPyPI + - name: Check tag + id: check-tag + uses: actions-ecosystem/action-regex-match@9e6c4fb3d5e898f505be7a1fb6e7b0a278f6665b # v2.0.2 + with: + text: ${{ github.ref }} + regex: '^refs/tags/[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+rc[0-9]+|rc[0-9]+)?$' + - name: Upload packages to GitHub + if: ${{ steps.check-tag.outputs.match != '' }} + uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: dist/* + tag: ${{ github.ref }} + overwrite: true + file_glob: true + - name: Publish packages to PyPI + if: ${{ steps.check-tag.outputs.match != '' }} + uses: pypa/gh-action-pypi-publish@e53eb8b103ffcb59469888563dc324e3c8ba6f06 # v1.8.12 + - name: Publish packages to TestPyPI + if: ${{ steps.check-tag.outputs.match == '' }} + uses: pypa/gh-action-pypi-publish@e53eb8b103ffcb59469888563dc324e3c8ba6f06 # v1.8.12 + with: + repository-url: https://test.pypi.org/legacy/ + verbose: true diff --git a/pyproject.toml b/pyproject.toml index e92978be..70ed8e0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name = "openvino_xai" -version = "1.0.0rc0" +version = "1.0.0rc01" dependencies = [ "openvino-dev==2023.2", "opencv-python", @@ -26,7 +26,7 @@ readme = "README.md" license = {file = "LICENSE"} keywords = ["openvino-toolkit", "explainable-ai", "xai", "cnn", "transformer", "black-box", "white-box"] classifiers = [ - "License :: OSI Approved :: MIT Apache Software License", + "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", ]