Skip to content

Commit

Permalink
Use PyAnsys actions and add labels (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy-Grigg committed May 10, 2024
1 parent 1adf2d0 commit 8614e5d
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 47 deletions.
35 changes: 35 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- name: bug
description: Something isn't working
color: d42a34

- name: dependencies
description: Related with project dependencies
color: ffc0cb

- name: documentation
description: Improvements or additions to documentation
color: 0677ba

- name: enhancement
description: New features or code improvements
color: FFD827

- name: good first issue
description: Easy to solve for newcomers
color: 62ca50

- name: maintenance
description: Package and maintenance related
color: f78c37

- name: release
description: Anything related to an incoming release
color: ffffff

- name: api-definition
description: Changes to the API definition file
color: daf7a6

- name: code-gen
description: Changes to the code generation project configuration
color: d12dc9
68 changes: 27 additions & 41 deletions .github/workflows/build_and_test_library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ on:
- "*"
paths:
- "ansys-grantami-serverapi-openapi/**"
- ".github/workflows/build_and_test_library.yml"
pull_request:
paths:
- "ansys-grantami-serverapi-openapi/**"
- ".github/workflows/build_and_test_library.yml"

env:
MAIN_PYTHON_VERSION: '3.10'
LIBRARY_NAME: 'ansys-grantami-serverapi-openapi'

jobs:


tests:
name: "Test Python ${{ matrix.python-version }}"
runs-on: ubuntu-latest
Expand All @@ -39,14 +41,14 @@ jobs:
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
working-directory: ansys-grantami-serverapi-openapi
working-directory: ${{ env.LIBRARY_NAME }}

- name: "Test with pytest"
working-directory: ansys-grantami-serverapi-openapi
working-directory: ${{ env.LIBRARY_NAME }}
run: poetry run pytest

- name: "Run mypy"
working-directory: ansys-grantami-serverapi-openapi
working-directory: ${{ env.LIBRARY_NAME }}
run: poetry run mypy

build-library:
Expand All @@ -68,66 +70,50 @@ jobs:
python -m pip install build twine
- name: "Create source and wheel artifacts"
working-directory: ansys-grantami-serverapi-openapi
working-directory: ${{ env.LIBRARY_NAME }}
run: |
python -m build .
- name: "Validate integrity of artifacts"
working-directory: ansys-grantami-serverapi-openapi
working-directory: ${{ env.LIBRARY_NAME }}
run: |
python -m twine check dist/*
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
with:
name: ansys-grantami-serverapi-openapi-wheel
path: ansys-grantami-serverapi-openapi/dist/
name: ${{ env.LIBRARY_NAME }}-artifacts
path: ${{ env.LIBRARY_NAME }}/dist/
retention-days: 7


release:
name: "Release"
if: contains(github.ref, 'refs/tags') && github.event_name == 'push'
needs: build-library
runs-on: ubuntu-latest
needs: [build-library]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
steps:
- name: "Release to public PyPI"
uses: ansys/actions/release-pypi-public@v6
with:
library-name: ${{ env.LIBRARY_NAME }}
twine-username: "__token__"
twine-token: ${{ secrets.PYPI_TOKEN }}

- name: "Checkout the project"
uses: actions/checkout@v4

- name: "Set up Python ${{ env.MAIN_PYTHON_VERSION }}"
uses: actions/setup-python@v5
- name: "Release to private PyPI"
uses: ansys/actions/release-pypi-private@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
library-name: ${{ env.LIBRARY_NAME }}
twine-username: "__token__"
twine-token: ${{ secrets.PYPI_TOKEN }}

- name: "Download distribution artifacts"
uses: actions/download-artifact@v4
with:
name: ansys-grantami-serverapi-openapi-wheel
path: ~/dist

- name: "Install Python dependencies"
run: |
python -m pip install --upgrade pip twine
- name: "Release to private PyPI"
run: |
python -m twine upload --verbose --skip-existing --non-interactive ~/dist/*.whl
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}
TWINE_REPOSITORY_URL: "https://pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/upload"

- name: "Release to public PyPI"
run: |
python -m twine upload --verbose --skip-existing --non-interactive ~/dist/*.whl
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
TWINE_REPOSITORY_URL: "https://upload.pypi.org/legacy/"
name: ${{ env.LIBRARY_NAME }}-artifacts
path: ${{ env.LIBRARY_NAME }}-artifacts

- name: "Release to GitHub"
uses: softprops/action-gh-release@v2
with:
files: ~/dist/ansys-grantami-serverapi-openapi-wheel/*.whl
generate_release_notes: true
files: ${{ env.LIBRARY_NAME }}-artifacts/*.whl
generate_release_notes: true
23 changes: 17 additions & 6 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,32 @@ on:
pull_request:
push:
branches: [ main ]
paths:
- '../labels.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

label-syncer:
name: Syncer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: micnncim/action-label-syncer@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

labeler:
name: Set labels
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:

- name: Label based on changed files
uses: actions/labeler@v5
with:
Expand All @@ -34,8 +45,8 @@ jobs:
issue-number: ${{ github.event.pull_request.number }}
body: |
Please add one of the following labels to add this contribution to the Release Notes :point_down:
- [api-definition](https://github.com/ansys/grantami-serverapi-openapi/pulls?q=label%3Aapi-definition)
- [code-gen](https://github.com/ansys/grantami-serverapi-openapi/pulls?q=label%3Acode-gen+)
- [enhancement](https://github.com/ansys/grantami-serverapi-openapi/pulls?q=label%3Aenhancement+)
- [maintenance](https://github.com/ansys/grantami-serverapi-openapi/pulls?q=label%3Amaintenance+)
- [bug](https://github.com/ansys/grantami-serverapi-openapi/pulls?q=label%3Abug+)
- [api-definition](https://github.com/ansys/grantami-bomanalytics-openapi/pulls?q=label%3Aapi-definition)
- [code-gen](https://github.com/ansys/grantami-bomanalytics-openapi/pulls?q=label%3Acode-gen+)
- [enhancement](https://github.com/ansys/grantami-bomanalytics-openapi/pulls?q=label%3Aenhancement+)
- [maintenance](https://github.com/ansys/grantami-bomanalytics-openapi/pulls?q=label%3Amaintenance+)
- [bug](https://github.com/ansys/grantami-bomanalytics-openapi/pulls?q=label%3Abug+)

0 comments on commit 8614e5d

Please sign in to comment.