From 0e0c0cd7f2f121c440395c8b8700932140ca4429 Mon Sep 17 00:00:00 2001 From: Teal Date: Mon, 26 Aug 2024 10:00:33 -0700 Subject: [PATCH] [FIX] Have publishing workflow test before publishing (#55) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squash of 6 commits: * ci: 🛠️ Allow build & release to trigger and wait on tests. * ci: 🚀 run on push to allow workflow triggering. * ci: ♻️ restore push behavior w/tags * ci: 🐛 Fix if statemetns for workflow_dispatch * ci: 🚀 Uncomment publish statement for non-workflow_dispatch runs * ci: 🛠️ Disallow minting tokens on workflow dispatch. * chore(README): 🎨 Space in README --- .github/workflows/build_tests.yml | 1 + .github/workflows/publish_pypi.yml | 19 ++++++++++++++++++- .github/workflows/source_tests.yml | 1 + README.md | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index 028df5c6..99d574d1 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -8,6 +8,7 @@ on: schedule: - cron: "20 1 * * mon" workflow_dispatch: + workflow_call: defaults: run: diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index a7089557..4210c31c 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -5,9 +5,20 @@ on: tags: # Matches any tags; tags are only used for versioning in this project. - '*' + workflow_dispatch: jobs: + source_test: + # This runs the test files on the repository before publishing it. + name: Source tests + uses: ./.github/workflows/source_tests.yml + + build_test: + name: Build tests + uses: ./.github/workflows/build_tests.yml + deploy: + needs: [source_test, build_test] runs-on: ubuntu-latest permissions: @@ -29,15 +40,21 @@ jobs: virtualenvs-create: false - name: Update version (kept at 0.0.0) in pyproject.toml and build + if: ${{ github.event_name != 'workflow_dispatch' }} run: | poetry version ${{ github.ref_name }} poetry version poetry build - name: Mint token + if: ${{ github.event_name != 'workflow_dispatch' }} id: mint uses: tschm/token-mint-action@v1.0.3 - name: Publish the package with poetry + # Allow workflow dispatch to trigger this job, but don't allow it + # to publish the package to PyPI. + if: ${{ github.event_name != 'workflow_dispatch' }} run: | - poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token }}' + echo "PUBLISHING!!!! ✨🚀" + poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token }}' diff --git a/.github/workflows/source_tests.yml b/.github/workflows/source_tests.yml index 79e69d31..9601eefe 100644 --- a/.github/workflows/source_tests.yml +++ b/.github/workflows/source_tests.yml @@ -8,6 +8,7 @@ on: schedule: - cron: "20 1 * * mon" workflow_dispatch: + workflow_call: defaults: run: diff --git a/README.md b/README.md index e671382a..ba562d2b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ [pypi package version badge]: https://badge.fury.io/py/astrodata.svg [source test status badge]: https://github.com/GeminiDRSoftware/astrodata/actions/workflows/source_tests.yml/badge.svg [build test status badge]: https://github.com/GeminiDRSoftware/astrodata/actions/workflows/build_tests.yml/badge.svg + `astrodata` =============