-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update versioning and release to be automatic (#197)
Also silences warnings when numba and scipy are not available; closes #189
- Loading branch information
Showing
9 changed files
with
151 additions
and
39 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,18 @@ | ||
import sys | ||
import os | ||
|
||
|
||
def parse(message): | ||
if "#prerelease" in message: | ||
return 'prerelease' | ||
|
||
for pre in ['pre', '']: | ||
for level in ['patch', 'minor', 'major']: | ||
if f'#{pre}{level}' in message: | ||
return f'{pre}{level}' | ||
|
||
return 'patch' | ||
|
||
|
||
message = os.environ['github_event_head_commit_message'] | ||
print(parse(message)) |
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,11 @@ | ||
import sys | ||
|
||
|
||
def parse(f): | ||
import tomli | ||
with open(f, "rb") as fp: | ||
pyproject = tomli.load(fp) | ||
return pyproject["tool"]["poetry"]["version"] | ||
|
||
|
||
print(parse(sys.argv[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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import re | ||
import fileinput | ||
|
||
|
||
def update(version): | ||
files = ("pyproject.toml", "setup.py", "src/quaternion/__init__.py") | ||
pattern = re.compile('^(__version__|version) *= *".*?"') | ||
replacement = r'\1 = "' + version + '"' | ||
with fileinput.input(files=files, inplace=True) as f: | ||
for line in f: | ||
print(pattern.sub(replacement, line), end="") | ||
|
||
|
||
version = os.environ["new_version"] | ||
|
||
update(version) |
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 |
---|---|---|
|
@@ -8,12 +8,54 @@ name: tests | |
on: [push] | ||
|
||
jobs: | ||
|
||
get_new_version: | ||
name: Get new version number | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.get_version.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install tomli | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip tomli | ||
- name: Install poetry | ||
shell: bash | ||
run: | | ||
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | ||
python get-poetry.py -y | ||
- name: Bump version | ||
id: get_version | ||
shell: bash | ||
env: | ||
github_event_head_commit_message: ${{ github.event.head_commit.message }} | ||
run: | | ||
export version_bump_rule=$(python .github/scripts/parse_bump_rule.py) | ||
echo "version_bump_rule: '${version_bump_rule}'" | ||
$HOME/.poetry/bin/poetry version "${version_bump_rule}" | ||
export new_version=$(python .github/scripts/parse_version.py pyproject.toml) | ||
echo "new_version: '${new_version}'" | ||
echo "::set-output name=version::${new_version}" | ||
build_wheels: | ||
needs: get_new_version | ||
name: Build wheels on ${{ matrix.os }} for ${{matrix.archs}} | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" | ||
if: >- | ||
!contains(github.event.head_commit.message, '[skip ci]') | ||
&& !contains(github.event.head_commit.message, '[skip tests]') | ||
strategy: | ||
fail-fast: false | ||
|
@@ -49,6 +91,13 @@ jobs: | |
with: | ||
python-version: '3.8' | ||
|
||
- name: Update versions | ||
shell: bash | ||
run: | | ||
export new_version=${{needs.get_new_version.outputs.version}} | ||
echo "Updating version to '${new_version}'" | ||
python .github/scripts/update_versions.py | ||
- name: Install cibuildwheel | ||
run: | | ||
python -m pip install --upgrade pip | ||
|
@@ -64,6 +113,7 @@ jobs: | |
|
||
|
||
build_sdist: | ||
needs: get_new_version | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
outputs: | ||
|
@@ -76,53 +126,60 @@ jobs: | |
with: | ||
python-version: '3.8' | ||
|
||
- name: Update versions | ||
shell: bash | ||
run: | | ||
export new_version=${{needs.get_new_version.outputs.version}} | ||
echo "Updating version to '${new_version}'" | ||
python .github/scripts/update_versions.py | ||
- name: Build sdist | ||
run: | | ||
python -m pip install oldest-supported-numpy | ||
python setup.py sdist | ||
- name: Get version | ||
id: get_version | ||
run: | | ||
# Note: This requires numpy, so it must run after the build step | ||
export new_version=$(python -c 'import setup; print(setup.version)') | ||
echo "Found version ${new_version}" | ||
echo "::set-output name=version::${new_version}" | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
path: dist/*.tar.gz | ||
|
||
|
||
upload_pypi: | ||
needs: [build_wheels, build_sdist] | ||
name: Tag and release | ||
runs-on: ubuntu-latest | ||
if: "github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[no release]')" | ||
# # upload to PyPI on every tag starting with 'v' | ||
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') | ||
# # publish when a GitHub Release is created | ||
# if: github.event_name == 'release' && github.event.action == 'published' | ||
if: >- | ||
github.ref == 'refs/heads/main' | ||
&& !contains(github.event.head_commit.message, '[no release]') | ||
&& (success() || contains(github.event.head_commit.message, '[skip tests]')) | ||
steps: | ||
- uses: actions/checkout@v2 | ||
# Needed for the git actions | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: artifact | ||
path: dist | ||
|
||
- name: Get latest version | ||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Update versions | ||
shell: bash | ||
run: | | ||
export new_version=${{needs.build_sdist.outputs.version}} | ||
echo "new_version: '${new_version}'" | ||
export new_version=${{needs.get_new_version.outputs.version}} | ||
echo "Updating version to '${new_version}'" | ||
echo "new_version=${new_version}" >> $GITHUB_ENV | ||
python .github/scripts/update_versions.py | ||
- name: Tag and push new version | ||
shell: bash | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git commit -m "Update version for new release" pyproject.toml setup.py src/quaternion/__init__.py | ||
git tag -a "v${new_version}" -m "Version ${new_version}" | ||
git status | ||
git push --follow-tags # Will not trigger new workflow because it uses GITHUB_TOKEN | ||
|
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,12 @@ | ||
[tool.poetry] | ||
name = "quaternion" | ||
version = "2022.3.0" | ||
description = "Add a quaternion dtype to NumPy" | ||
readme = "README.md" | ||
license = "MIT" | ||
authors = ["Michael Boyle <[email protected]>"] | ||
homepage = "https://github.com/moble/quaternion" | ||
|
||
[tool.pytest.ini_options] | ||
minversion = "6.0" | ||
norecursedirs = ".* build dist *.egg-info install ENV" | ||
|
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