-
Notifications
You must be signed in to change notification settings - Fork 8
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
CI: Publish workflow (PyPI) #83
Merged
+113
−6
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e1ce855
CI: Add workflow for publishing to PyPI
danielhollas fcf3ec3
Use static version
danielhollas 25d2bb8
Fix version in docs
danielhollas c4f3068
Add check-release-tag jobs
danielhollas 608249f
Fix
danielhollas 5ec5c60
TO BE REVERTED: Don't skip tag check on PR
danielhollas 6ea0335
Tweak
danielhollas 671dbc2
Revert "TO BE REVERTED: Don't skip tag check on PR"
danielhollas 26b710c
Bump version to a1
danielhollas 183576e
TO BE REVERTED: Disable PyPI publish
danielhollas f15affd
Revert "TO BE REVERTED: Disable PyPI publish"
danielhollas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# WARNING: This file should not be renamed! | ||
# It's name is tied to Trusted Publishing on PyPI. | ||
# | ||
# Deploy to PyPI when a release tag vX.Y.Z is created. | ||
# Will only be published to PyPI if the git tag matches the released version. | ||
# Additionally, creating a "test-release" label on a PR will trigger a publish to TestPyPI. | ||
name: Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
pull_request: | ||
types: [labeled] | ||
|
||
env: | ||
FORCE_COLOR: 1 | ||
|
||
jobs: | ||
|
||
check-release-tag: | ||
name: Check tag version | ||
if: >- | ||
github.repository == 'aiidateam/aiida-test-cache' && | ||
github.event_name == 'push' && | ||
github.ref_type == 'tag' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
- name: Check version tag | ||
run: | | ||
ver=$(python -c "from tomllib import load;p=load(open('pyproject.toml','rb'));print(p['project']['version'])") | ||
errormsg="tag version '${{ github.ref_name }}' != 'v$ver' specified in pyproject.toml" | ||
if [ "v${ver}" != "${{ github.ref_name }}" ]; then echo "$errormsg"; exit 1; fi | ||
|
||
dist: | ||
name: Distribution build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: hynek/build-and-inspect-python-package@v2 | ||
|
||
|
||
test-publish: | ||
needs: [dist] | ||
name: Publish to TestPyPI | ||
if: >- | ||
github.repository == 'aiidateam/aiida-test-cache' && | ||
github.event_name == 'pull_request' && | ||
github.event.action == 'labeled' && | ||
github.event.label.name == 'test-release' | ||
environment: | ||
name: testpypi | ||
url: https://test.pypi.org/p/aiida-test-cache/ | ||
permissions: | ||
id-token: write | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: Packages | ||
path: dist | ||
|
||
- uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
# Remove the PR label which triggered this release, | ||
# but only if the release failed. Presumably, in this case we might want | ||
# to fix whatever caused the failure and re-trigger the test release. | ||
# If the release succeeded, re-triggering the release would fail anyway, | ||
# unless the version would be bumped again. | ||
- name: Remove test-release label | ||
if: failure() | ||
uses: actions-ecosystem/action-remove-labels@v1 | ||
with: | ||
labels: test-release | ||
|
||
|
||
pypi-publish: | ||
name: Publish release to PyPI | ||
needs: [dist, check-release-tag] | ||
if: >- | ||
github.repository == 'aiidateam/aiida-test-cache' && | ||
github.event_name == 'push' && | ||
github.ref_type == 'tag' | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/aiida-test-cache/ | ||
permissions: | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: Packages | ||
path: dist | ||
|
||
- uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
"""A pytest plugin for testing AiiDA plugins.""" | ||
|
||
__version__ = '0.1.0.dev1' | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think the
__version__
attribute is very useful for this package and it complicates package management so I am removing it. Dissenters will be pointed to a lengthy discussion thread on CPython forum full of people arguing about this. :-DThere 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.
Please point me to the lengthy discussion, would be a nice read material after dinner.
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.
🤣
https://discuss.python.org/t/brainstorming-eliminating-dynamic-metadata/71405
Here you go. :-)