Add settings service #181
Workflow file for this run
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: GitHub CI | |
# run only on main branch. This avoids duplicated actions on PRs | |
on: | |
pull_request: | |
push: | |
tags: | |
- "*" | |
branches: | |
- main | |
env: | |
MAIN_PYTHON_VERSION: "3.10" | |
PACKAGE_NAME: "ansys.api.additive" | |
DEFINITION_VERSION: "v0" | |
DOTNET_VERSION: "6.0.x" | |
GITHUB_NUGET_REPO: "https://nuget.pkg.github.com/ansys/index.json" | |
jobs: | |
build: | |
name: Build python package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
- name: Install build requirements | |
run: | | |
pip install -U pip | |
pip install build | |
- name: Build | |
run: python -m build | |
- name: Install | |
run: pip install dist/*.whl | |
- name: Test import | |
run: | | |
mkdir tmp | |
cd tmp | |
python -c "import ${{ env.PACKAGE_NAME }}.${{ env.DEFINITION_VERSION }}; print('Sucessfully imported ${{ env.PACKAGE_NAME}}.${{ env.DEFINITION_VERSION }}')" | |
python -c "from ${{ env.PACKAGE_NAME }} import __version__; print(__version__)" | |
- name: Upload packages | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ansys-api-additive-packages | |
path: dist/ | |
retention-days: 7 | |
nuget: | |
name: Build nuget package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
# Publish | |
- name: Build nuget package | |
run: | | |
dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "${{ env.GITHUB_NUGET_REPO }}" | |
version=$(find . -name VERSION -exec cat "{}" \;) | |
rm -rf nuget_package | |
dotnet pack csharp/Ansys.Api.Additive.csproj -c Release -o nuget_package -p:Version=${version} | |
- name: Upload package artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ansys-api-additive-packages | |
path: nuget_package/ | |
retention-days: 7 | |
release: | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags') | |
needs: [build, nuget] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
- uses: actions/download-artifact@v3 | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Upload to Public PyPi | |
run: | | |
pip install twine | |
twine upload --skip-existing ./**/*.whl | |
twine upload --skip-existing ./**/*.tar.gz | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
generate_release_notes: true | |
files: | | |
./**/*.whl | |
./**/*.tar.gz | |
./**/*.nupkg | |
publish-nuget-package: | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags') | |
needs: [nuget] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- uses: actions/download-artifact@v3 | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Publish nuget package | |
run: | | |
dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "${{ env.GITHUB_NUGET_REPO }}" | |
dotnet nuget push ./**/*.nupkg --source github |