-
-
Notifications
You must be signed in to change notification settings - Fork 28
Isolate package build and publish #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # This workflow is triggered two ways: | ||
| # | ||
| # 1. When a tag is created, the workflow will upload the package to | ||
| # 1. When a commit is made, the workflow will upload the package to | ||
| # test.pypi.org. | ||
| # 2. When a release is made, the workflow will upload the package to pypi.org. | ||
| # | ||
|
|
@@ -9,49 +9,84 @@ | |
| name: Upload package | ||
|
|
||
| on: | ||
| release: | ||
| types: [created] | ||
| push: | ||
| tags: | ||
| - '*' | ||
| pull_request: | ||
| release: | ||
| types: | ||
| - published | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| FORCE_COLOR: 1 | ||
|
|
||
| jobs: | ||
| deploy: | ||
| # Always build & lint package. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is redundant, it is covered by the name. |
||
| build-package: | ||
| name: Build & verify package | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| fetch-depth: 0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? Does it need the entire history? |
||
| persist-credentials: false | ||
|
|
||
| - uses: hynek/build-and-inspect-python-package@fe0a0fb1925ca263d076ca4f2c13e93a6e92a33e # v2.17.0 | ||
|
|
||
| # Publish to Test PyPI on every commit on main. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this fail due to duplicate version numbers? |
||
| release-test-pypi: | ||
| name: Publish in-dev package to test.pypi.org | ||
| if: | | ||
| github.repository_owner == 'python' | ||
| && github.event_name == 'push' | ||
| && github.ref == 'refs/heads/main' | ||
| runs-on: ubuntu-latest | ||
| needs: build-package | ||
|
|
||
| permissions: | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Download packages built by build-and-inspect-python-package | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: Packages | ||
| path: dist | ||
|
|
||
| - name: Publish to Test PyPI | ||
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 | ||
| with: | ||
| repository-url: https://test.pypi.org/legacy/ | ||
|
|
||
| # Publish to PyPI on GitHub Releases. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly redundant with the name and comment. |
||
| release-pypi: | ||
| name: Publish to PyPI | ||
| # Only run for published releases. | ||
| if: | | ||
| github.repository_owner == 'python' | ||
| && github.event.action == 'published' | ||
| runs-on: ubuntu-latest | ||
| needs: build-package | ||
|
|
||
| environment: | ||
| name: release | ||
| url: https://pypi.org/p/tzdata | ||
| url: >- | ||
| https://pypi.org/project/tzdata/${{ | ||
| github.event.release.tag_name | ||
| }} | ||
|
|
||
| permissions: | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: '3.x' | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -U tox | ||
| - name: Create tox environments | ||
| run: | | ||
| tox -p -e py,build --notest | ||
| - name: Run tests | ||
| run: | | ||
| tox -e py | ||
| - name: Build package | ||
| run: | | ||
| tox -e build | ||
| - name: Publish package (TestPyPI) | ||
| if: github.event_name == 'push' | ||
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 | ||
| with: | ||
| repository-url: https://test.pypi.org/legacy/ | ||
| verbose: true | ||
| - name: Publish package | ||
| if: github.event_name == 'release' | ||
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 | ||
| with: | ||
| verbose: true | ||
| - name: Download packages built by build-and-inspect-python-package | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: Packages | ||
| path: dist | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I won't be able to do releases in one PR now, right? It'll require me to do two.