Skip to content

Commit

Permalink
Autobuild: Move Changelog generation to the workflow
Browse files Browse the repository at this point in the history
Previously, the autobuild changelog (autoLatestChangelog.md) which is
used for the Github release body, was generated as part of the
"analyse_git_reference.py" script. It does not seem logical for an
analysis script to have a side effect of producing a Changelog file.
Also, the file name (autoLatestChangelog.md) was hardcoded in two places
and had to match (workflow + script).

With this commit, the changelog generation call (.github/actions_scripts/getChangelog.pl)
is moved to the workflow. This follows the principle of least surprise
and moves the output file name usage to a single file (the workflow).

Fixes: jamulussoftware#2480
  • Loading branch information
hoffie committed Jun 18, 2022
1 parent 5ecb376 commit f21ecdf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
18 changes: 3 additions & 15 deletions .github/actions_scripts/analyse_git_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,8 @@ def get_git_hash():
]).decode('ascii').strip()


def write_changelog(version):
changelog = subprocess.check_output([
'perl',
f'{REPO_PATH}/.github/actions_scripts/getChangelog.pl',
f'{REPO_PATH}/ChangeLog',
version,
])
with open(f'{REPO_PATH}/autoLatestChangelog.md', 'wb') as f:
f.write(changelog)


def get_build_version(jamulus_pro_version):
def get_build_version():
jamulus_pro_version = get_version_from_jamulus_pro()
if "dev" in jamulus_pro_version:
name = "{}-{}".format(jamulus_pro_version, get_git_hash())
print("building an intermediate version: ", name)
Expand All @@ -59,9 +49,7 @@ def set_github_variable(varname, varval):
print("::set-output name={}::{}".format(varname, varval))


jamulus_pro_version = get_version_from_jamulus_pro()
write_changelog(jamulus_pro_version)
build_version = get_build_version(jamulus_pro_version)
build_version = get_build_version()

fullref = os.environ['GITHUB_REF']
publish_to_release = bool(re.match(r'^refs/tags/r\d+_\d+_\d+\S*$', fullref))
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Determine release version, type and prerelease variables and generate Changelog
run: python3 ${{ github.workspace }}/.github/actions_scripts/analyse_git_reference.py
- name: Determine release version, type and prerelease variables
run: ./.github/actions_scripts/analyse_git_reference.py
id: get-build-vars

- name: Extract Changelog for the Github release body
if: steps.get-build-vars.outputs.PUBLISH_TO_RELEASE == 'true'
run: ./.github/actions_scripts/getChangelog.pl ChangeLog $(grep -oP 'VERSION = \K\w[^\s\\]*' Jamulus.pro) > autoLatestChangelog.md

- name: Remove release ${{steps.get-build-vars.outputs.RELEASE_TAG}}, if existing
if: steps.get-build-vars.outputs.PUBLISH_TO_RELEASE == 'true'
continue-on-error: true
Expand Down

0 comments on commit f21ecdf

Please sign in to comment.