Skip to content

Commit

Permalink
update the pypi release script to use github action with auth token a…
Browse files Browse the repository at this point in the history
…nd (#593)

update github action versions
  • Loading branch information
imatiach-msft authored Jan 12, 2024
1 parent 2901465 commit b361593
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 208 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/CI-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
runs-on: ${{ matrix.operatingSystem }}

steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.pythonVersion }}
Expand Down Expand Up @@ -67,13 +67,13 @@ jobs:
shell: bash -l {0}
run: |
pytest ./tests -m "not notebooks" -s -v --cov=${{ matrix.packageDirectory }} --cov-report=xml --cov-report=html
- name: Upload code coverage results
uses: actions/upload-artifact@v3
- if: ${{ matrix.pythonVersion == '3.8' }}
name: Upload code coverage results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.packageDirectory }}-code-coverage-results
path: htmlcov
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

- if: ${{ matrix.pythonVersion == '3.8' }}
name: Upload to codecov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Code-Scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/release-interpret-community.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Release interpret-community to PyPI

# trigger manually only ("collaborator" or more permissions required)
on:
workflow_dispatch:
inputs:
releaseType:
description: "Test or Prod PyPI?"
required: true
default: "Test"

jobs:
release-build:
runs-on: ubuntu-latest

steps:
- name: fail if Test nor Prod
if: ${{ ! (github.event.inputs.releaseType == 'Test' || github.event.inputs.releaseType == 'Prod') }}
run: |
echo "Only Test or Prod can be used."
exit 1
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.8

- name: Install pytorch on non-MacOS
shell: bash -l {0}
run: |
conda install --yes --quiet pytorch torchvision cpuonly -c pytorch
- name: update and upgrade pip, setuptools, wheel, and twine
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine
- name: Install dev dependencies
shell: bash -l {0}
run: |
pip install -r requirements-dev.txt
- name: Install visualization dependencies
shell: bash -l {0}
# install scikit-learn to workaround raiwidgets dependency
run: |
pip install raiwidgets
pip install -r requirements-vis.txt
pip install --upgrade scikit-learn
pip install --upgrade "shap<=0.44.0"
- name: Install test dependencies
shell: bash -l {0}
run: |
pip install -r requirements-test.txt
- name: pip freeze
shell: bash -l {0}
run: pip freeze

- name: build wheel for interpret-community
shell: bash -l {0}
run: python setup.py sdist bdist_wheel
working-directory: python

# run tests before publishing to PyPI
- name: install interpret-community wheel locally
shell: bash -l {0}
run: find ./dist/ -name '*.whl' -exec pip install {} \;
working-directory: python

- name: run interpret-community tests
shell: bash -l {0}
run: pytest ./tests -m "not notebooks" -s -v

- name: Upload a interpret-community build result
uses: actions/upload-artifact@v4
with:
name: interpret_community
path: python/dist/

# publish to PyPI
- name: Publish interpret-community package to Test PyPI
if: ${{ github.event.inputs.releaseType == 'Test' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN_INTERPRET_COMMUNITY }}
repository_url: https://test.pypi.org/legacy/
packages_dir: python/dist/
- name: Publish interpret-community package to PyPI
if: ${{ github.event.inputs.releaseType == 'Prod' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN_INTERPRET_COMMUNITY }}
packages_dir: python/dist/
200 changes: 0 additions & 200 deletions devops/PyPI-Release.yml

This file was deleted.

0 comments on commit b361593

Please sign in to comment.