-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from CasperWA/test_release
Automatically publish version tags to PyPI via GH Actions
- Loading branch information
Showing
10 changed files
with
103 additions
and
21 deletions.
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,24 @@ | ||
import os | ||
|
||
try: | ||
from optimade import __version__ | ||
except ImportError: | ||
raise ImportError( | ||
"optimade needs to be installed prior to running 'assert_version.py'" | ||
) | ||
|
||
package_version = f"v{__version__}" | ||
|
||
tag_version = os.getenv("TAG_VERSION") | ||
tag_version = tag_version[len("refs/tags/") :] | ||
|
||
if tag_version == package_version: | ||
print(f"The versions match: tag:'{tag_version}' == package:'{package_version}'") | ||
exit(0) | ||
|
||
print( | ||
f"""The current package version '{package_version}' does not equal the tag version '{tag_version}'. | ||
Update package version by \"invoke setver --new-ver='{tag_version[1:]}'\" and re-commit. | ||
Please remove the tag from both GitHub and your local repository and try again!""" | ||
) | ||
exit(1) |
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,7 +1,7 @@ | ||
#!/bin/bash | ||
diff=$(jsondiff openapi.json local_openapi.json); | ||
|
||
if [ ! "$diff" = "{}" ]; then | ||
echo -e "Generated OpenAPI spec did not match committed version. Diff:\n$diff"; | ||
if [ ! "$diff" = "{}" ]; then | ||
echo -e "Generated OpenAPI spec did not match committed version.\nRun 'invoke update_openapijson' and re-commit.\nDiff:\n$diff"; | ||
exit 1; | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Publish on PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
# After vMajor.Minor.Patch _anything_ is allowed (without "/") ! | ||
- v[0-9]+.[0-9]+.[0-9]+* | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'Materials-Consortia/optimade-python-tools' && startsWith(github.ref, 'refs/tags/v') | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v1 | ||
|
||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Upgrade setuptools and install package | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools | ||
python -m pip install -e . | ||
- name: Assert package version | ||
env: | ||
TAG_VERSION: ${{ github.ref }} | ||
run: python ./.ci/assert_version.py | ||
|
||
- name: Build source distribution | ||
run: python ./setup.py sdist | ||
|
||
# This tests that publication to PyPI is possible, before properly publishing | ||
- name: Publish package to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.test_pypi_password }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
|
||
- name: Publish package to PyPI | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} |
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,7 +1,13 @@ | ||
repos: | ||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
hooks: | ||
- id: black | ||
default_language_version: | ||
python: python3.7 | ||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
exclude: README.md | ||
- id: check-yaml | ||
- id: check-json |
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
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
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