From 4ccd558112b511beaae3594e199b9cf3743b2c13 Mon Sep 17 00:00:00 2001 From: w-bonelli Date: Fri, 11 Nov 2022 13:00:13 -0500 Subject: [PATCH] refactor(ci): create release and publish to PyPI when tags pushed --- .github/workflows/release.yml | 40 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b0ce225..de932691 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,11 @@ -name: Publish release and package +name: Release on: push: - branches: - - master + tags: + - v* jobs: release: - name: Release + name: Release & publish runs-on: ubuntu-latest steps: @@ -17,16 +17,13 @@ jobs: with: python-version: 3.7 - - name: Upgrade pip and install build and twine + - name: Install Python packages run: | pip install --upgrade pip pip install build twine + pip install . - - name: Base modflow_devtools installation - run: | - pip --verbose install . - - - name: Print package version + - name: Print version run: | python -c "import modflow_devtools; print(modflow_devtools.__version__)" @@ -37,16 +34,17 @@ jobs: - name: Check distribution run: | twine check --strict dist/* - + + - name: Publish package + if: ${{ env.TWINE_USERNAME != '' }} + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + twine upload dist/* + - name: Create release - uses: "marvinpinto/action-automatic-releases@latest" + uses: marvinpinto/action-automatic-releases@latest with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - - # todo: set repo secrets and enable - # - name: Publish package - # env: - # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - # run: | - # twine upload dist/* \ No newline at end of file + prerelease: true + repo_token: ${{ github.token }} \ No newline at end of file