mirror of
https://github.com/OPM/ResInsight.git
synced 2024-12-28 09:51:44 -06:00
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:
parent
8a41d5a085
commit
8f83d25c9d
52
.github/workflows/ResInsightWithCache.yml
vendored
52
.github/workflows/ResInsightWithCache.yml
vendored
@ -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/
|
||||
|
||||
|
@ -19,3 +19,5 @@
|
||||
RESINSIGHT_MAJOR_VERSION = "@RESINSIGHT_MAJOR_VERSION@"
|
||||
RESINSIGHT_MINOR_VERSION = "@RESINSIGHT_MINOR_VERSION@"
|
||||
RESINSIGHT_PATCH_VERSION = "@RESINSIGHT_PATCH_VERSION@"
|
||||
|
||||
PYTHON_GRPC_PROTOC_VERSION = "@PYTHON_GRPC_PROTOC_VERSION@"
|
@ -77,7 +77,7 @@ if(Protobuf_FOUND)
|
||||
# Find gRPC installation Looks for gRPCConfig.cmake file installed by gRPC's
|
||||
# cmake installation.
|
||||
find_package(gRPC CONFIG REQUIRED)
|
||||
message(STATUS "Using gRPC ${gRPC_VERSION}")
|
||||
message(STATUS "Generate C++ code using grpc : ${gRPC_VERSION}")
|
||||
|
||||
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
|
||||
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
|
||||
@ -144,6 +144,12 @@ add_custom_target(PipInstall)
|
||||
|
||||
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||
message(STATUS "Using Python Executable: ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}")
|
||||
|
||||
execute_process(COMMAND "${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}" -m grpc_tools.protoc --version
|
||||
OUTPUT_VARIABLE PYTHON_GRPC_PROTOC_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
message(STATUS "Using Python grpc protoc compiler: ${PYTHON_GRPC_PROTOC_VERSION}")
|
||||
else()
|
||||
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not install Python client code")
|
||||
endif()
|
||||
|
@ -6,7 +6,7 @@ with open('README.md') as f:
|
||||
with open('LICENSE') as f:
|
||||
license = f.read()
|
||||
|
||||
RIPS_DIST_VERSION = '1'
|
||||
RIPS_DIST_VERSION = '2'
|
||||
|
||||
setup(
|
||||
name='rips',
|
||||
@ -19,5 +19,5 @@ setup(
|
||||
license=license,
|
||||
packages=['rips'],
|
||||
package_data={'rips': ['*.py', 'generated/*.py', 'PythonExamples/*.py', 'tests/*.py']},
|
||||
install_requires=['grpcio>=1.20.0', 'protobuf', 'wheel']
|
||||
install_requires=['grpcio', 'protobuf', 'wheel']
|
||||
)
|
Loading…
Reference in New Issue
Block a user