fix: use pyvista to resample VTU files onto a grid instead of a Paraview batch script #46
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
name: release | |
concurrency: release | |
env: | |
PYTHON_VERSION_BUMP: 3.8 | |
PYTHON_VERSION_RELEASE: 3.8 | |
on: | |
pull_request_target: | |
branches: [main, develop] | |
types: [closed] | |
jobs: | |
bump-version: | |
if: | |
| # skip if: trying to re-run; PR is closed without merging; '[skip release]' is in the PR title; or if merging any branch other than pre_release_branch into release_branch | |
( | |
github.run_attempt == '1' | |
&& github.event.pull_request.merged | |
&& ! contains(github.event.pull_request.title, '[skip release]') | |
&& ( | |
github.event.pull_request.base.ref == 'develop' || ( | |
github.event.pull_request.base.ref == 'main' | |
&& github.event.pull_request.head.ref == 'develop' | |
) | |
) | |
) | |
runs-on: ubuntu-latest | |
outputs: | |
new_tag_name: ${{ steps.get_new_tag.outputs.new_tag_name }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # get all history and tags | |
ref: ${{ github.event.pull_request.base.ref }} | |
token: ${{ secrets.LIGHTFORM_ACTIONS_TOKEN }} | |
- run: | | |
git config user.name lightform-bot | |
git config user.email [email protected] | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON_VERSION_BUMP }} | |
- name: Get git-chglog executable | |
run: | | |
wget https://github.com/git-chglog/git-chglog/releases/download/v0.15.0/git-chglog_0.15.0_linux_amd64.tar.gz | |
tar --extract --file git-chglog_0.15.0_linux_amd64.tar.gz git-chglog | |
- name: Install commitizen | |
run: pip install commitizen | |
- name: Manipulate tags (stable release) | |
if: github.event.pull_request.base.ref == 'main' | |
run: | |
| # delete all pre-release tags, set current version to the latest stable release, | |
CUR_PRE_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "CUR_PRE_TAG is: $CUR_PRE_TAG" | |
echo "cur_pre_tag=$CUR_PRE_TAG" >> $GITHUB_ENV | |
git tag -l | awk '/^(v[0-9]+\.[0-9]+\.[0-9]+(a|b|rc).*)$/ {print $1}' | xargs git tag -d | |
- name: Get current tag | |
run: | | |
CUR_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "CUR_TAG is: $CUR_TAG" | |
echo "cur_tag=$CUR_TAG" >> $GITHUB_ENV | |
- name: Commitizen bump (pre-release) # Bump version strings (pre-release) and add a new tag; commit | |
if: github.event.pull_request.base.ref == 'develop' | |
run: cz bump --prerelease alpha | |
- name: Commitizen bump # First update version number to latest stable release, then bump to new stable release, add a new tag and commit | |
if: github.event.pull_request.base.ref == 'main' | |
run: | | |
python3 -c " | |
from commitizen.bump import update_version_in_files | |
update_version_in_files( | |
current_version='${{ env.cur_pre_tag }}'.lstrip('v'), | |
new_version='${{ env.cur_tag }}'.lstrip('v'), | |
files=['pyproject.toml', 'cipher_parse/_version.py'], | |
)" | |
cz bump | |
- name: Get new tag | |
id: get_new_tag | |
run: | | |
NEW_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "NEW_TAG is: $NEW_TAG" | |
echo "new_tag=$NEW_TAG" >> $GITHUB_ENV | |
echo "::set-output name=new_tag_name::$NEW_TAG" | |
- name: Write requirements.txt for binder | |
run: | | |
new_tag=${{ env.new_tag }} | |
new_version="${new_tag:1}" | |
echo "cipher-parse==${new_version}" > .binder/requirements.txt | |
git add .binder/requirements.txt | |
- name: Generate CHANGELOG (stable release) | |
if: github.event.pull_request.base.ref == 'main' | |
run: | | |
./git-chglog --output CHANGELOG.md | |
git add CHANGELOG.md | |
- name: Generate CHANGELOG-dev (pre-release) | |
if: github.event.pull_request.base.ref == 'develop' | |
run: | | |
./git-chglog --output CHANGELOG-dev.md | |
git add CHANGELOG-dev.md | |
- name: Push new CHANGELOG | |
run: | | |
git tag -d ${{ env.new_tag }} | |
git commit --amend --no-edit | |
git tag ${{ env.new_tag }} | |
git push && git push origin ${{ env.new_tag }} | |
- name: Rebase into develop branch if exists (stable release) | |
if: github.event.pull_request.base.ref == 'main' | |
run: | | |
exists_in_remote=$(git ls-remote --heads origin refs/heads/develop) | |
echo "exists_in_remote: $exists_in_remote" | |
if [[ -n $exists_in_remote ]]; then | |
export SKIP=end-of-file-fixer | |
git checkout develop | |
git pull | |
git rebase main | |
git push -u origin develop | |
else | |
echo "No develop branch to merge into." | |
fi | |
- name: Generate incremental CHANGELOG for GitHub release body (stable release) | |
if: github.event.pull_request.base.ref == 'main' | |
run: | | |
./git-chglog --template .chglog/RELEASE.tpl.md --output CHANGELOG_increment.md ${{ env.cur_tag }}.. | |
cat CHANGELOG_increment.md | |
- name: Generate incremental CHANGELOG for GitHub release body (pre-release) | |
if: github.event.pull_request.base.ref == 'develop' | |
run: | | |
./git-chglog --template .chglog/RELEASE.tpl.md --output CHANGELOG_increment.md ${{ env.new_tag }} | |
cat CHANGELOG_increment.md | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: CHANGELOG_increment | |
path: CHANGELOG_increment.md | |
release-github-PyPI: | |
needs: [bump-version] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.base.ref }} # otherwise we get the ref when the workflow started (missing above commit) | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON_VERSION_RELEASE }} | |
- name: Cache the virtualenv | |
uses: actions/cache@v2 | |
with: | |
path: ./.venv | |
key: venv-release-${{ hashFiles('**/poetry.lock') }} | |
- name: Install poetry | |
run: python -m pip install poetry | |
- name: Configure poetry | |
run: | | |
poetry config virtualenvs.in-project true | |
poetry config installer.modern-installation false | |
- name: Install dependencies | |
run: poetry install | |
- name: Build (for PyPI) | |
run: poetry build | |
- run: mkdir release-artifacts | |
- uses: actions/download-artifact@v2 | |
with: | |
path: release-artifacts | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Release | |
id: release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body_path: release-artifacts/CHANGELOG_increment/CHANGELOG_increment.md | |
tag_name: ${{ needs.bump-version.outputs.new_tag_name }} | |
prerelease: ${{ github.event.pull_request.base.ref == 'develop' }} | |
- name: Publish (to https://upload.pypi.org/legacy/) | |
run: | | |
poetry config repositories.pypi https://upload.pypi.org/legacy/ | |
poetry config pypi-token.pypi ${{ secrets.PYPI_CIPHER_PARSE }} | |
poetry publish --repository pypi |