diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3638d35..9ef8512 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,68 +9,52 @@ on: branches: - main +env: + MAIN_PYTHON_VERSION: '3.9' + PACKAGE_NAME: 'ansys-api-acp' + jobs: - build: - name: Build package + build-library: + name: "Build package" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: "3.7" - - 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 ansys.api.acp.v0; print('Sucessfully imported ansys.api.acp.v0')" - python -c "from ansys.api.acp import __version__; print(__version__)" - - name: Upload packages - uses: actions/upload-artifact@v2 + - name: "Build library source and wheel artifacts" + uses: ansys/actions/build-library@v4 with: - name: ansys-api-acp-packages - path: dist/ - retention-days: 7 + library-name: ${{ env.PACKAGE_NAME }} - Release: - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - needs: [build] + check-version: + name: "Check version is bumped" runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' steps: - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.10 + - name: "Check out repository" + uses: actions/checkout@v2 + - name: "Check version is changed" + run: | + git fetch origin $BASE_BRANCH - - uses: actions/download-artifact@v2 + VERSION_FILE=$(find src/ -name VERSION) - - name: Display structure of downloaded files - run: ls -R + NUM_CHARS=$(git diff --ignore-all-space origin/$BASE_BRANCH -- $VERSION_FILE | wc -c) - # uncomment the following section to permit upload to public PyPI + if [ $NUM_CHARS -eq 0 ]; then + echo "Version is not bumped. Please update the version in $VERSION_FILE" + exit 1 + fi + env: + BASE_BRANCH: ${{ github.event.pull_request.base.ref }} - # - 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 + release-pypi-private: + name: "Release to private PyPI" + runs-on: ubuntu-latest + needs: [build-library] + if: github.event_name == 'push' && github.ref_type == 'branch' && github.ref == 'refs/heads/main' + steps: + - name: "Release to the private PyPI repository" + uses: ansys/actions/release-pypi-private@v4 with: - generate_release_notes: true - files: | - ./**/*.whl - ./**/*.tar.gz - ./**/*.pdf + library-name: ${{ env.PACKAGE_NAME }} + twine-username: "__token__" + twine-token: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }} diff --git a/src/ansys/api/acp/VERSION b/src/ansys/api/acp/VERSION index 1821d33..dcaf5a8 100644 --- a/src/ansys/api/acp/VERSION +++ b/src/ansys/api/acp/VERSION @@ -1 +1 @@ -0.1.0.dev0 +0.1.0.dev1