Merge pull request #2101 from solliancenet/cj-polling-interval #259
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish NuGet & PyPi Packages | |
on: | |
push: | |
branches: | |
- release/** | |
workflow_dispatch: | |
env: | |
DOTNET_VERSION: '8.0.x' | |
PYTHON_VERSION: '3.11.x' | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Validate branch | |
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} | |
run: | | |
echo "This workflow can only be run on release branches." | |
exit 1 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up .NET Core SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Run versioning script | |
run: bash ./versioning.sh | |
id: versioning | |
# .NET Build and Pack Steps | |
- name: Build Common | |
working-directory: ./src/dotnet/Common | |
run: dotnet build --configuration Release -p:GITHUB_ACTIONS=true | |
- name: Build Configuration | |
working-directory: ./src/dotnet/Configuration | |
run: dotnet build --configuration Release -p:GITHUB_ACTIONS=true | |
- name: Build CoreClient | |
working-directory: ./src/dotnet/CoreClient | |
run: dotnet build --configuration Release -p:GITHUB_ACTIONS=true | |
- name: Build ManagementClient | |
working-directory: ./src/dotnet/ManagementClient | |
run: dotnet build --configuration Release -p:GITHUB_ACTIONS=true | |
- name: Pack Common | |
working-directory: ./src/dotnet/Common | |
run: dotnet pack --configuration Release /p:PackageVersion=${{ steps.versioning.outputs.version }} -p:GITHUB_ACTIONS=true --output ./nupkg | |
- name: Pack Configuration | |
working-directory: ./src/dotnet/Configuration | |
run: dotnet pack --configuration Release /p:PackageVersion=${{ steps.versioning.outputs.version }} -p:GITHUB_ACTIONS=true --output ./nupkg | |
- name: Pack CoreClient | |
working-directory: ./src/dotnet/CoreClient | |
run: dotnet pack --configuration Release /p:PackageVersion=${{ steps.versioning.outputs.version }} -p:GITHUB_ACTIONS=true --output ./nupkg | |
- name: Pack ManagementClient | |
working-directory: ./src/dotnet/ManagementClient | |
run: dotnet pack --configuration Release /p:PackageVersion=${{ steps.versioning.outputs.version }} -p:GITHUB_ACTIONS=true --output ./nupkg | |
# .NET Publish Steps | |
- name: Publish Common to NuGet | |
working-directory: ./src/dotnet/Common | |
run: dotnet nuget push ./nupkg/*.Common.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
- name: Publish Configuration to NuGet | |
working-directory: ./src/dotnet/Configuration | |
run: dotnet nuget push ./nupkg/*.Configuration.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
- name: Publish CoreClient to NuGet | |
working-directory: ./src/dotnet/CoreClient | |
run: dotnet nuget push ./nupkg/*.Client.Core.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
- name: Publish ManagementClient to NuGet | |
working-directory: ./src/dotnet/ManagementClient | |
run: dotnet nuget push ./nupkg/*.Client.Management.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
# Python Build and Publish Steps | |
- name: Build Python Package | |
run: | | |
cd ./src/python/PythonSDK | |
python -m pip install --upgrade build | |
python -m build | |
- name: Publish Python Package to PyPI | |
working-directory: ./src/python/PythonSDK/dist | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }} | |
run: | | |
python -m pip install --upgrade twine | |
python -m twine upload --repository-url https://upload.pypi.org/legacy/ *.tar.gz *.whl |