From 5ecb37695b314fc48e94ac787cf852773262a24b Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Wed, 6 Apr 2022 13:29:18 +0200 Subject: [PATCH 1/6] Autobuild: Don't hardcode python path in analyse_git_reference.py --- .github/actions_scripts/analyse_git_reference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions_scripts/analyse_git_reference.py b/.github/actions_scripts/analyse_git_reference.py index d093bde21f..61e4541a51 100755 --- a/.github/actions_scripts/analyse_git_reference.py +++ b/.github/actions_scripts/analyse_git_reference.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # This script is trigged from the Github Autobuild workflow. # It analyzes Jamulus.pro and git push details (tag vs. branch, etc.) to decide # - whether a release should be created, From c4d957337d3c70ce44110da4a90c42aed998f051 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Wed, 6 Apr 2022 13:30:04 +0200 Subject: [PATCH 2/6] Autobuild: Move Changelog generation to the workflow 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: #2480 --- .github/actions_scripts/analyse_git_reference.py | 13 +------------ .github/workflows/autobuild.yml | 8 ++++++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/actions_scripts/analyse_git_reference.py b/.github/actions_scripts/analyse_git_reference.py index 61e4541a51..4a8c40a29b 100755 --- a/.github/actions_scripts/analyse_git_reference.py +++ b/.github/actions_scripts/analyse_git_reference.py @@ -32,17 +32,6 @@ 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): if "dev" in jamulus_pro_version: name = "{}-{}".format(jamulus_pro_version, get_git_hash()) @@ -60,7 +49,7 @@ def set_github_variable(varname, varval): jamulus_pro_version = get_version_from_jamulus_pro() -write_changelog(jamulus_pro_version) +set_github_variable("JAMULUS_PRO_VERSION", jamulus_pro_version) build_version = get_build_version(jamulus_pro_version) fullref = os.environ['GITHUB_REF'] diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 7cd4c3d1e2..51b8bc66f7 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -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 ${{ steps.get-build-vars.outputs.JAMULUS_PRO_VERSION }} > 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 From 979ef535beb0ad306e0fc94a808f394a3f5f1aad Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Wed, 6 Apr 2022 13:43:21 +0200 Subject: [PATCH 3/6] Autobuild: Improve variable naming/coding style in analyse_git_reference.py --- .github/actions_scripts/analyse_git_reference.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions_scripts/analyse_git_reference.py b/.github/actions_scripts/analyse_git_reference.py index 4a8c40a29b..81470652ce 100755 --- a/.github/actions_scripts/analyse_git_reference.py +++ b/.github/actions_scripts/analyse_git_reference.py @@ -34,13 +34,13 @@ def get_git_hash(): def get_build_version(jamulus_pro_version): if "dev" in jamulus_pro_version: - name = "{}-{}".format(jamulus_pro_version, get_git_hash()) - print("building an intermediate version: ", name) - return name + version = "{}-{}".format(jamulus_pro_version, get_git_hash()) + print(f"building an intermediate version: {version}") + return version - name = jamulus_pro_version - print("building a release version: ", name) - return name + version = jamulus_pro_version + print(f"building a release version: {version}") + return version def set_github_variable(varname, varval): From abd6fa7c0e7e4aa216d54bbeb0e749b423afc13b Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Wed, 6 Apr 2022 13:46:24 +0200 Subject: [PATCH 4/6] Autobuild: Move .github/action_scripts to .github/autobuild This also renames the two scripts to better reflect what they do. --- .../getChangelog.pl => autobuild/extractVersionChangelog.pl} | 0 .../analyse_git_reference.py => autobuild/get_build_vars.py} | 0 .github/workflows/autobuild.yml | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename .github/{actions_scripts/getChangelog.pl => autobuild/extractVersionChangelog.pl} (100%) rename .github/{actions_scripts/analyse_git_reference.py => autobuild/get_build_vars.py} (100%) diff --git a/.github/actions_scripts/getChangelog.pl b/.github/autobuild/extractVersionChangelog.pl similarity index 100% rename from .github/actions_scripts/getChangelog.pl rename to .github/autobuild/extractVersionChangelog.pl diff --git a/.github/actions_scripts/analyse_git_reference.py b/.github/autobuild/get_build_vars.py similarity index 100% rename from .github/actions_scripts/analyse_git_reference.py rename to .github/autobuild/get_build_vars.py diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 51b8bc66f7..7f44cd4eb8 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -68,12 +68,12 @@ jobs: uses: actions/checkout@v2 - name: Determine release version, type and prerelease variables - run: ./.github/actions_scripts/analyse_git_reference.py + run: ./.github/autobuild/get_build_vars.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 ${{ steps.get-build-vars.outputs.JAMULUS_PRO_VERSION }} > autoLatestChangelog.md + run: ./.github/autobuild/extractVersionChangelog.pl ChangeLog ${{ steps.get-build-vars.outputs.JAMULUS_PRO_VERSION }} > autoLatestChangelog.md - name: Remove release ${{steps.get-build-vars.outputs.RELEASE_TAG}}, if existing if: steps.get-build-vars.outputs.PUBLISH_TO_RELEASE == 'true' From b7745ded9929d78aacaed8dd8eb45843764f9cd7 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Sat, 18 Jun 2022 16:43:11 +0200 Subject: [PATCH 5/6] Autobuild: Use a variable instead of hardcoding the release changelog path twice Related: #2480 --- .github/workflows/autobuild.yml | 6 ++++-- .gitignore | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 7f44cd4eb8..1bf2610eac 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -62,6 +62,8 @@ jobs: publish_to_release: ${{ steps.get-build-vars.outputs.PUBLISH_TO_RELEASE }} upload_url: ${{ steps.create-release.outputs.upload_url }} build_version: ${{ steps.get-build-vars.outputs.BUILD_VERSION }} + env: + release_changelog_path: ./.github_release_changelog.md steps: - name: Checkout code @@ -73,7 +75,7 @@ jobs: - name: Extract Changelog for the Github release body if: steps.get-build-vars.outputs.PUBLISH_TO_RELEASE == 'true' - run: ./.github/autobuild/extractVersionChangelog.pl ChangeLog ${{ steps.get-build-vars.outputs.JAMULUS_PRO_VERSION }} > autoLatestChangelog.md + run: ./.github/autobuild/extractVersionChangelog.pl ChangeLog ${{ steps.get-build-vars.outputs.JAMULUS_PRO_VERSION }} > ${{ env.release_changelog_path }} - name: Remove release ${{steps.get-build-vars.outputs.RELEASE_TAG}}, if existing if: steps.get-build-vars.outputs.PUBLISH_TO_RELEASE == 'true' @@ -94,7 +96,7 @@ jobs: with: tag_name: ${{ steps.get-build-vars.outputs.RELEASE_TAG }} release_name: ${{ steps.get-build-vars.outputs.RELEASE_TITLE }} - body_path: autoLatestChangelog.md + body_path: ${{ env.release_changelog_path }} prerelease: ${{ steps.get-build-vars.outputs.IS_PRERELEASE }} draft: false diff --git a/.gitignore b/.gitignore index 1f49dc501b..b91209eab8 100644 --- a/.gitignore +++ b/.gitignore @@ -45,5 +45,5 @@ distributions/jamulus-server.desktop Debug-iphoneos/ Jamulus.xcodeproj jamulus_plugin_import.cpp -autoLatestChangelog.md +.github_release_changelog.md debian/ From e97d32d3951648816d97ee2bad5a123b2f0bec55 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Sat, 18 Jun 2022 18:15:27 +0200 Subject: [PATCH 6/6] Autobuild: Avoid log output in build-vars helper function Related: https://github.com/jamulussoftware/jamulus/pull/2656/files/42e085c2254984162ebf964154ca8aa4041a9046#r900988442 --- .github/autobuild/get_build_vars.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/autobuild/get_build_vars.py b/.github/autobuild/get_build_vars.py index 81470652ce..f6a5ca55e0 100755 --- a/.github/autobuild/get_build_vars.py +++ b/.github/autobuild/get_build_vars.py @@ -35,12 +35,10 @@ def get_git_hash(): def get_build_version(jamulus_pro_version): if "dev" in jamulus_pro_version: version = "{}-{}".format(jamulus_pro_version, get_git_hash()) - print(f"building an intermediate version: {version}") - return version + return 'intermediate', version version = jamulus_pro_version - print(f"building a release version: {version}") - return version + return 'release', version def set_github_variable(varname, varval): @@ -50,7 +48,8 @@ def set_github_variable(varname, varval): jamulus_pro_version = get_version_from_jamulus_pro() set_github_variable("JAMULUS_PRO_VERSION", jamulus_pro_version) -build_version = get_build_version(jamulus_pro_version) +build_type, build_version = get_build_version(jamulus_pro_version) +print(f'building a version of type "{build_type}": {build_version}') fullref = os.environ['GITHUB_REF'] publish_to_release = bool(re.match(r'^refs/tags/r\d+_\d+_\d+\S*$', fullref))