Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Release action (AMReX-Astro#1025)
Browse files Browse the repository at this point in the history
This creates an action which will automatically create a release whenever a version is tagged that matches the format xx.xx. The release text is scraped from CHANGES.md using a python script. If no text is found matching the tag, then it is left blank.
  • Loading branch information
harpolea authored Jun 9, 2020
1 parent 52154e6 commit 9a43c87
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 35 deletions.
Binary file not shown.
36 changes: 36 additions & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '[0-9][0-9].[0-9][0-9]'

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get the version
id: get_version
run: echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Set release text
id: release_txt
run: |
python3 .github/workflows/get_release_txt.py ${{ env.VERSION }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ env.RELEASE_TXT }}
draft: false
prerelease: false
37 changes: 37 additions & 0 deletions .github/workflows/get_release_txt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3

"""
Get the text for the release from CHANGES.md
"""

import re
import sys

if __name__ == "__main__":
if len(sys.argv) < 2:
print('No version provided!')
else:
gen_version_re = re.compile(r'#\s(\d\d\.\d\d)')
this_version_re = re.compile(f'#\s{sys.argv[1]}')

with open('CHANGES.md', 'r') as file:
txt = file.read()
m = re.search(this_version_re, txt)
if m:
# find next date
m_next = re.search(gen_version_re, txt[m.end():])
if m_next:
txt = txt[m.end():m.end()+m_next.start()].strip()
else:
txt = txt[m.end():].strip()
else:
txt = ""

# we now need to substitute characters in the string so that
# the action can deal with line breaks
txt = txt.replace('%', '%25')
txt = txt.replace('\n', '%0A')
txt = txt.replace('\r', '%0D')
txt = txt.replace('%0A *', '%0A*')

print(f'::set-env name=RELEASE_TXT::{txt}')
33 changes: 0 additions & 33 deletions .github/workflows/slack-notify.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Docs/source/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ Example notebook

Using the plotfiles generated in the example in the :doc:`getting_started` section, here we demonstrate how to use ``yt`` to load and visualize data. This section was generated from a Jupyter notebook which can be found in ``Docs/source/yt_example.ipynb`` in the Castro repo.

.. include:: yt_example.rst
.. include:: yt_example.rst
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ numpy
IPython>=3
nbconvert
pandoc
jupyter
jupyter

0 comments on commit 9a43c87

Please sign in to comment.