-
Notifications
You must be signed in to change notification settings - Fork 29
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 #433 from hakonanes/add-automatic-creation-of-tagg…
…ed-release Add automatic creation of tagged release draft
- Loading branch information
Showing
10 changed files
with
118 additions
and
12 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: build | ||
name: Build | ||
|
||
on: [push, pull_request] | ||
|
||
|
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,43 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019-2021 The kikuchipy developers | ||
# | ||
# This file is part of kikuchipy. | ||
# | ||
# 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 kikuchipy. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import re | ||
|
||
from outdated import check_outdated | ||
|
||
|
||
with open("../../kikuchipy/release.py") as fid: | ||
for line in fid: | ||
if line.startswith("version"): | ||
branch_version = line.strip().split(" = ")[-1][1:-1] | ||
|
||
# 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 = check_outdated("kikuchipy", branch_version) | ||
except ValueError as e: | ||
pypi_version = re.findall(r"\s([\d.]+)", e.args[0])[1] | ||
make_release = True | ||
|
||
# These three prints are collected by a bash script using `eval` and | ||
# passed to GitHub Action environment variables to be used in a workflow | ||
print(make_release) | ||
print(pypi_version) | ||
print(branch_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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Perhaps make a tagged release | ||
|
||
# Trigger workflow when commits to the main branch contain a change in the | ||
# kikuchipy/release.py file. This is because this workflow should only run when a | ||
# tagged release draft is to be made. | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "kikuchipy/release.py" | ||
|
||
jobs: | ||
make-tagged-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- 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 | ||
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: kikuchipy ${{ env.BRANCH_VERSION }} | ||
commitish: main | ||
body: | | ||
kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns. | ||
See the [changelog](https://kikuchipy.org/en/latest/changelog.html) for all updates from the previous release. | ||
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
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
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