From c72a741accf98fa15eb2a89edfec8666d4846dfa Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 31 Aug 2023 10:32:58 -0400 Subject: [PATCH] prepare for release --- .github/workflows/create_release.yml | 36 +++++++++++++++++++++++++++ .github/workflows/get_release_txt.py | 37 ++++++++++++++++++++++++++++ CHANGES.md | 3 +++ 3 files changed, 76 insertions(+) create mode 100644 .github/workflows/create_release.yml create mode 100644 .github/workflows/get_release_txt.py create mode 100644 CHANGES.md diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 0000000..2e7d0fb --- /dev/null +++ b/.github/workflows/create_release.yml @@ -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@v3 + + - name: Get the version + id: get_version + run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Set release text + id: release_txt + run: | + python3 .github/workflows/get_release_txt.py ${{ env.VERSION }} >> $GITHUB_ENV + + - 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 \ No newline at end of file diff --git a/.github/workflows/get_release_txt.py b/.github/workflows/get_release_txt.py new file mode 100644 index 0000000..50530c1 --- /dev/null +++ b/.github/workflows/get_release_txt.py @@ -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'"RELEASE_TXT=${{{txt}}}"') \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..d101c21 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,3 @@ +# 23.09 + +Initial release of initial_models. All code has been converted to C++