From e64370b9e23ed4190abe9ae8d487ef4f018439a2 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Fri, 5 Feb 2021 11:24:28 -0500 Subject: [PATCH] ENH: Workflow to publish to PyPI on GitHub release. Allow [ci skip] --- .github/workflows/ci_workflows.yml | 21 +++++++++++++++++ .github/workflows/publish.yml | 38 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci_workflows.yml b/.github/workflows/ci_workflows.yml index 65e1bac..3e1ef16 100644 --- a/.github/workflows/ci_workflows.yml +++ b/.github/workflows/ci_workflows.yml @@ -9,8 +9,25 @@ on: - master jobs: + cancel_ci: + name: Mandatory checks before CI + runs-on: ubuntu-latest + outputs: + run_next: ${{ steps.skip_ci_step.outputs.run_next }} + steps: + - name: Check skip CI + uses: OpenAstronomy/action-skip-ci@main + id: skip_ci_step + with: + NO_FAIL: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # The rest only run if above are done + pep_and_audit: runs-on: ubuntu-16.04 + needs: cancel_ci + if: needs.cancel_ci.outputs.run_next == 'true' steps: - name: Checkout code uses: actions/checkout@v2 @@ -38,6 +55,8 @@ jobs: # Python 3.7 + Numpy 1.19 resulted in NaN results, so we downgrade Numpy. initial_tests: runs-on: ubuntu-16.04 + needs: cancel_ci + if: needs.cancel_ci.outputs.run_next == 'true' steps: - name: Checkout code uses: actions/checkout@v2 @@ -60,6 +79,8 @@ jobs: dev_deps_tests: runs-on: ubuntu-latest + needs: cancel_ci + if: needs.cancel_ci.outputs.run_next == 'true' steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9933ff2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: Release + +on: + release: + types: [released] + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-latest + if: github.repository == 'spacetelescope/exovetter' + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install python-build and twine + run: python -m pip install build "twine>=3.3" + + - name: Build package + run: python -m build --sdist --wheel . + + - name: List result + run: ls -l dist + + - name: Check dist + run: python -m twine check --strict dist/* + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }}