Publish Python package to pypi when a commit is tagged

* Publish to pypi from main workflow
* Remove pinning
* Include version info for proto tool in RiaVersionInfo.py
This commit is contained in:
Magne Sjaastad
2023-06-29 14:07:04 +02:00
committed by GitHub
parent 8a41d5a085
commit 8f83d25c9d
4 changed files with 58 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ concurrency:
cancel-in-progress: true
jobs:
ResInsight-x64-buildcache:
build:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
@@ -34,6 +34,7 @@ jobs:
build-python-module: true,
execute-unit-tests: true,
unity-build: true,
publish-to-pypi: false,
}
- {
name: "Ubuntu Latest gcc",
@@ -45,6 +46,7 @@ jobs:
build-python-module: true,
execute-unit-tests: true,
unity-build: false,
publish-to-pypi: true,
}
- {
name: "Ubuntu Latest clang",
@@ -56,6 +58,7 @@ jobs:
build-python-module: true,
execute-unit-tests: true,
unity-build: false,
publish-to-pypi: false,
}
steps:
- name: Checkout
@@ -79,10 +82,9 @@ jobs:
run: echo "${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}"
- name: Install dependencies
# Make sure protobuf version is compatible with grpc - https://github.com/OPM/ResInsight/issues/9304
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r GrpcInterface/Python/requirements.txt
- name: Use CMake
uses: lukka/get-cmake@latest
@@ -232,12 +234,52 @@ jobs:
env:
RESINSIGHT_EXECUTABLE: ${{ runner.workspace }}/ResInsight/cmakebuild/ApplicationExeCode/ResInsight
run: |
cd GrpcInterface/Python/rips
cd GrpcInterface/Python
python setup.py sdist
cd rips
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pytest --console
- name: Upload artifact
- name: Upload python distribution folder
if: matrix.config.publish-to-pypi
uses: actions/upload-artifact@v3
with:
name: python-distribution
path: GrpcInterface/Python/dist
- name: Upload Windows install artifact
if: ${{contains( matrix.config.os, 'windows') }}
uses: actions/upload-artifact@v3
with:
name: ResInsight-${{ matrix.config.name }}
path: ${{ runner.workspace }}/ResInsight/cmakebuild/install
pypi-publish:
name: Upload release to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/rips
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
# If this is a tagged release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- name: Download python distribution folder
uses: actions/download-artifact@v3
with:
name: python-distribution
path: dist
- name: Display structure of downloaded files
run: ls -R
- name: Publish Python package to pypi
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
uses: pypa/gh-action-pypi-publish@release/v1
# uncomment the two lines below to publish to test PyPi
# with:
# repository-url: https://test.pypi.org/legacy/