-
Notifications
You must be signed in to change notification settings - Fork 52
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 #385 from hakonanes/prepare-release-v0.10
Merge develop into main for release v0.10.0
- Loading branch information
Showing
144 changed files
with
9,771 additions
and
5,758 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
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,55 @@ | ||
name: Perhaps make a tagged release | ||
|
||
# Trigger workflow when commits to the main branch contain a change in the | ||
# orix/__init__.py file. This is because this workflow should only run when a | ||
# tagged release draft is to be made. | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "orix/__init__.py" | ||
|
||
jobs: | ||
make-tagged-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v1 | ||
|
||
- name: Set up Python ${{ runner.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install outdated | ||
- name: Check whether a tagged release draft should be made | ||
run: | | ||
cd .github/workflows | ||
eval x=($(python perhaps_make_tagged_release_draft.py)) | ||
echo "MAKE_RELEASE=${x[0]}" >> $GITHUB_ENV | ||
echo "PYPI_VERSION=${x[1]}" >> $GITHUB_ENV | ||
echo "BRANCH_VERSION=${x[2]}" >> $GITHUB_ENV | ||
- name: Make tagged release draft body from changelog | ||
if: ${{ env.MAKE_RELEASE == 'true' }} | ||
run: pandoc .github/workflows/release_part_in_changelog.rst -f rst -t markdown -o release_part_in_changelog.md --wrap=none | ||
|
||
- name: Make tagged release draft | ||
if: ${{ env.MAKE_RELEASE == 'true' }} | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
draft: true | ||
tag_name: v${{ env.BRANCH_VERSION }} | ||
release_name: orix ${{ env.BRANCH_VERSION }} | ||
commitish: main | ||
body_path: release_part_in_changelog.md | ||
prerelease: false |
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,85 @@ | ||
# Copyright 2019-2022 The orix developers | ||
# | ||
# This file is part of orix. | ||
# | ||
# kikuchipy is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# kikuchipy is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with orix. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import re | ||
|
||
from outdated import check_outdated | ||
from packaging.version import Version | ||
|
||
with open("../../orix/__init__.py") as fid: | ||
for line in fid: | ||
if line.startswith("__version__"): | ||
branch_version_str = line.strip().split(" = ")[-1][1:-1] | ||
break | ||
|
||
# Within a try/except because we don't want to throw the error if a new | ||
# tagged release draft is to be made, we just want to know if the branch | ||
# version is different (hopefully always newer if different) from the | ||
# PyPI version | ||
try: | ||
make_release, pypi_version_str = check_outdated("orix", branch_version_str) | ||
except ValueError as err: | ||
pattern = re.compile(r"([\d.]+)") # Any "word" with decimal digits and dots | ||
matches = [] | ||
for line in err.args[0].split(" "): | ||
if pattern.match(line) is not None: | ||
matches.append(line) | ||
pypi_version_str = matches[-1] | ||
make_release = True | ||
|
||
# Don't make a release if the version is a development version | ||
branch_version = Version(branch_version_str) | ||
pypi_version = Version(pypi_version_str) | ||
if branch_version.is_devrelease: | ||
make_release = False | ||
|
||
if make_release: | ||
# Determine which type of release this is (major, minor, patch?) | ||
if branch_version.major > pypi_version.major: | ||
release_type = "major" | ||
elif branch_version.minor > pypi_version.minor: | ||
release_type = "minor" | ||
else: | ||
release_type = "patch" | ||
|
||
# Write the relevant part of the changelog to a new file to be used | ||
# by the publish workflow | ||
with open("../../CHANGELOG.rst", mode="r") as f: | ||
content = f.readlines() | ||
changelog_start = 0 | ||
changelog_end = 0 | ||
for i, line in enumerate(content): | ||
if branch_version.base_version in line: | ||
changelog_start = i + 3 | ||
elif pypi_version.base_version in line: | ||
changelog_end = i - 1 | ||
break | ||
if changelog_start == 0: | ||
changelog_end = 0 | ||
with open("release_part_in_changelog.rst", mode="w") as f: | ||
f.write( | ||
f"orix {branch_version_str} is a {release_type} release of orix, an open-source Python library for handling orientations, rotations and crystal symmetry.\n\n" | ||
f"See below, the `changelog <https://orix.readthedocs.io/en/stable/changelog.html>`_ or the `GitHub changelog <https://github.com/pyxem/orix/compare/v{pypi_version_str}...v{branch_version_str}>`_ for all updates from the previous release.\n\n" | ||
) | ||
for line in content[changelog_start:changelog_end]: | ||
f.write(line) | ||
|
||
# These three prints are collected by a bash script using `eval` and | ||
# passed to the publish workflow environment variables | ||
print(make_release) | ||
print(pypi_version_str) | ||
print(branch_version_str) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.1.0 | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
- id: black-jupyter | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
name: isort (python) | ||
args: | ||
[ | ||
"--profile", | ||
"black", | ||
"--filter-files", | ||
"--force-sort-within-sections", | ||
] |
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.