From fe4c9139c13b3c56089b52611a805661eb01c514 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 30 Sep 2025 23:47:28 +0200 Subject: [PATCH 1/5] Print Git reference classification. --- .github/workflows/PrepareJob.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/PrepareJob.yml b/.github/workflows/PrepareJob.yml index 3c04269..21d40c9 100644 --- a/.github/workflows/PrepareJob.yml +++ b/.github/workflows/PrepareJob.yml @@ -153,7 +153,9 @@ jobs: pr_number="" version="" + printf "Classify Git reference '%s' " "${ref}" if [[ "${ref:0:11}" == "refs/heads/" ]]; then + printf "${ANSI_LIGHT_GREEN}[BRANCH]\n" ref_kind="branch" branch="${ref:11}" @@ -219,6 +221,7 @@ jobs: printf "commit${ANSI_NOCOLOR} on development branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.development_branch }}" fi elif [[ "${ref:0:10}" == "refs/tags/" ]]; then + printf "${ANSI_LIGHT_GREEN}[TAG]\n" ref_kind="tag" tag="${ref:10}" @@ -254,6 +257,7 @@ jobs: exit 1 fi elif [[ "${ref:0:10}" == "refs/pull/" ]]; then + printf "${ANSI_LIGHT_YELLOW}[PULL REQUEST]\n" ref_kind="pullrequest" pr_number=${ref:11} pr_number=${pr_number%%/*} @@ -261,6 +265,7 @@ jobs: printf "Pull Request check:\n" printf " Number: %s\n" "${pr_number}" else + printf "${ANSI_LIGHT_RED}[UNKNOWN]\n" printf "${ANSI_LIGHT_RED}Unknown Git reference '%s'.${ANSI_NOCOLOR}\n" "${{ github.ref }}" printf "::error title=Classify Commit::Unknown Git reference '%s'.\n" "${{ github.ref }}" exit 1 From 626d64ef6af51a83b84e3c0cb13980882568e4c7 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 1 Oct 2025 00:16:50 +0200 Subject: [PATCH 2/5] Updated classification outputs. --- .github/workflows/PrepareJob.yml | 123 +++++++++++++++++-------------- 1 file changed, 66 insertions(+), 57 deletions(-) diff --git a/.github/workflows/PrepareJob.yml b/.github/workflows/PrepareJob.yml index 21d40c9..e87baa7 100644 --- a/.github/workflows/PrepareJob.yml +++ b/.github/workflows/PrepareJob.yml @@ -65,6 +65,9 @@ on: ref_kind: description: "" value: ${{ jobs.Prepare.outputs.ref_kind }} + default_branch: + description: "" + value: ${{ jobs.Prepare.outputs.default_branch }} branch: description: "" value: ${{ jobs.Prepare.outputs.branch }} @@ -102,6 +105,7 @@ jobs: is_nightly_tag: ${{ steps.Classify.outputs.is_nightly_tag }} is_release_tag: ${{ steps.Classify.outputs.is_release_tag }} ref_kind: ${{ steps.Classify.outputs.ref_kind }} + default_branch: ${{ steps.Classify.outputs.default_branch }} branch: ${{ steps.Classify.outputs.branch }} tag: ${{ steps.Classify.outputs.tag }} version: ${{ steps.Classify.outputs.version || steps.FindPullRequest.outputs.pr_version }} @@ -136,6 +140,8 @@ jobs: ANSI_LIGHT_BLUE=$'\x1b[94m' ANSI_NOCOLOR=$'\x1b[0m' + export GH_TOKEN=${{ github.token }} + ref="${{ github.ref }}" on_default_branch="false" on_main_branch="false" @@ -159,74 +165,73 @@ jobs: ref_kind="branch" branch="${ref:11}" - printf "Get default branch name ... " - defaultBranch=$(gh repo view "${{ github.repository }}" --json defaultBranchRef --jq '.defaultBranchRef.name') + printf " Get default branch name ... " + defaultBranch=$(gh repo view "${{ github.repository }}" --json defaultBranchRef --jq '.defaultBranchRef.name' 2>&1) if [[ $? -eq 0 ]]; then - printf " ${ANSI_LIGHT_GREEN} [OK]\n" + printf "${ANSI_LIGHT_GREEN} [OK]\n" + + default_branch="${defaultBranch}" + printf " default_branch=%s\n" "${default_branch}" else - printf " ${ANSI_LIGHT_RED} [FAILED]\n" + printf "${ANSI_LIGHT_RED} [FAILED]\n" + printf " %s\n" "${default_branch}" fi - printf "Commit check:\n" + printf "Commit checks:\n" if [[ "${branch}" == "${defaultBranch}" ]]; then on_default_branch="true" - if [[ -z "$(git rev-list -1 --merges ${{ github.sha }}~1..${{ github.sha }})" ]]; then - is_regular_commit="true" - printf " ${ANSI_LIGHT_YELLOW}regular " - else - is_merge_commit="true" - printf " ${ANSI_LIGHT_GREEN}merge " - fi - printf "commit${ANSI_NOCOLOR} on default branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${defaultBranch}" + printMessage="default branch" + printBranch="${defaultBranch}" fi if [[ "${branch}" == "${{ inputs.main_branch }}" ]]; then on_main_branch="true" - if [[ -z "$(git rev-list -1 --merges ${{ github.sha }}~1..${{ github.sha }})" ]]; then - is_regular_commit="true" - printf " ${ANSI_LIGHT_YELLOW}regular " - else - is_merge_commit="true" - printf " ${ANSI_LIGHT_GREEN}merge " - fi - printf "commit${ANSI_NOCOLOR} on main branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.main_branch }}" + printMessage="main branch" + printBranch="${{ inputs.main_branch }}" fi if [[ "${branch}" == "${{ inputs.release_branch }}" ]]; then on_release_branch="true" - if [[ -z "$(git rev-list -1 --merges ${{ github.sha }}~1..${{ github.sha }})" ]]; then - is_regular_commit="true" - printf " ${ANSI_LIGHT_YELLOW}regular " - else - is_release_commit="true" - printf " ${ANSI_LIGHT_GREEN}release " - fi - printf "commit${ANSI_NOCOLOR} on release branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.release_branch }}" + printMessage="release branch" + printBranch="${{ inputs.release_branch }}" fi if [[ "${branch}" == "${{ inputs.development_branch }}" ]]; then on_dev_branch="true" - if [[ -z "$(git rev-list -1 --merges ${{ github.sha }}~1..${{ github.sha }})" ]]; then - is_regular_commit="true" - printf " ${ANSI_LIGHT_YELLOW}regular " - else - is_merge_commit="true" - printf " ${ANSI_LIGHT_GREEN}merge " + printMessage="development branch" + printBranch="${{ inputs.development_branch }}" + fi + + if [[ -z "$(git rev-list -1 --merges ${{ github.sha }}~1..${{ github.sha }})" ]]; then + is_regular_commit="true" + printf " ${ANSI_LIGHT_YELLOW}regular commit${ANSI_NOCOLOR} on ${printMessage} ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${printBranch}" + else + is_merge_commit="true" + printf " ${ANSI_LIGHT_GREEN}merge commit${ANSI_NOCOLOR} on ${printMessage} ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${printBranch}" + + printf " Merge kind " + if [[ "${on_main_branch}" == "true" ]]; then + is_release_commit="true" + printf "${ANSI_LIGHT_GREEN}[RELEASE]${ANSI_NOCOLOR}\n" + elif [[ "${on_version_branch}" == "true" ]]; then + is_release_commit="true" + printf "${ANSI_LIGHT_GREEN}[RELEASE]${ANSI_NOCOLOR}\n" + elif [[ "${on_release_branch}" == "true" ]]; then + is_prerelease_commit="true" + printf "${ANSI_LIGHT_YELLOW}[PRERELEASE]${ANSI_NOCOLOR}\n" fi - printf "commit${ANSI_NOCOLOR} on development branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.development_branch }}" fi elif [[ "${ref:0:10}" == "refs/tags/" ]]; then printf "${ANSI_LIGHT_GREEN}[TAG]\n" ref_kind="tag" tag="${ref:10}" - printf "Tag check:\n" - + printf "Tag checks:\n" printf " Check if tag is on main branch '%s' ... " "${{ inputs.main_branch }}" git branch --remotes --contains $(git rev-parse --verify "tags/${tag}~0") | grep "origin/${{ inputs.main_branch }}" > /dev/null if [[ $? -eq 0 ]]; then @@ -262,7 +267,7 @@ jobs: pr_number=${ref:11} pr_number=${pr_number%%/*} - printf "Pull Request check:\n" + printf "Pull Request checks:\n" printf " Number: %s\n" "${pr_number}" else printf "${ANSI_LIGHT_RED}[UNKNOWN]\n" @@ -271,6 +276,7 @@ jobs: exit 1 fi + printf "\nWriting output variables ...\n" tee --append "${GITHUB_OUTPUT}" < Date: Wed, 1 Oct 2025 00:37:02 +0200 Subject: [PATCH 3/5] Fixed timestamp format in inventory JSON. --- .github/workflows/PrepareJob.yml | 42 ++++++++++------------- .github/workflows/PublishReleaseNotes.yml | 4 ++- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/workflows/PrepareJob.yml b/.github/workflows/PrepareJob.yml index e87baa7..ab44762 100644 --- a/.github/workflows/PrepareJob.yml +++ b/.github/workflows/PrepareJob.yml @@ -165,56 +165,52 @@ jobs: ref_kind="branch" branch="${ref:11}" - printf " Get default branch name ... " + printf "Get default branch name ... " defaultBranch=$(gh repo view "${{ github.repository }}" --json defaultBranchRef --jq '.defaultBranchRef.name' 2>&1) if [[ $? -eq 0 ]]; then printf "${ANSI_LIGHT_GREEN} [OK]\n" default_branch="${defaultBranch}" - printf " default_branch=%s\n" "${default_branch}" + printf " default_branch=%s\n" "${default_branch}" else printf "${ANSI_LIGHT_RED} [FAILED]\n" - printf " %s\n" "${default_branch}" + printf " %s\n" "${default_branch}" fi printf "Commit checks:\n" + printf " Commit kind " + if [[ -z "$(git rev-list -1 --merges ${{ github.sha }}~1..${{ github.sha }})" ]]; then + is_regular_commit="true" + printf "${ANSI_LIGHT_YELLOW}[REGULAR]${ANSI_NOCOLOR}\n" + else + is_merge_commit="true" + printf "${ANSI_LIGHT_GREEN}[MERGE]${ANSI_NOCOLOR}\n" + fi + printf "Branch checks:\n" if [[ "${branch}" == "${defaultBranch}" ]]; then on_default_branch="true" - - printMessage="default branch" - printBranch="${defaultBranch}" + printf " Commit on default branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${defaultBranch}" fi if [[ "${branch}" == "${{ inputs.main_branch }}" ]]; then on_main_branch="true" - - printMessage="main branch" - printBranch="${{ inputs.main_branch }}" + printf " Commit on main branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.main_branch }}" fi if [[ "${branch}" == "${{ inputs.release_branch }}" ]]; then on_release_branch="true" - - printMessage="release branch" - printBranch="${{ inputs.release_branch }}" + printf " Commit on release branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.release_branch }}" fi if [[ "${branch}" == "${{ inputs.development_branch }}" ]]; then on_dev_branch="true" - - printMessage="development branch" - printBranch="${{ inputs.development_branch }}" + printf " Commit on development branch ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${{ inputs.development_branch }}" fi - if [[ -z "$(git rev-list -1 --merges ${{ github.sha }}~1..${{ github.sha }})" ]]; then - is_regular_commit="true" - printf " ${ANSI_LIGHT_YELLOW}regular commit${ANSI_NOCOLOR} on ${printMessage} ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${printBranch}" - else - is_merge_commit="true" - printf " ${ANSI_LIGHT_GREEN}merge commit${ANSI_NOCOLOR} on ${printMessage} ${ANSI_LIGHT_BLUE}'%s'${ANSI_NOCOLOR}\n" "${printBranch}" - - printf " Merge kind " + if [[ "${is_merge_commit}" == "true" ]]; then + printf "Release checks:\n" + printf " Release kind " if [[ "${on_main_branch}" == "true" ]]; then is_release_commit="true" printf "${ANSI_LIGHT_GREEN}[RELEASE]${ANSI_NOCOLOR}\n" diff --git a/.github/workflows/PublishReleaseNotes.yml b/.github/workflows/PublishReleaseNotes.yml index 588c29a..36c090a 100644 --- a/.github/workflows/PublishReleaseNotes.yml +++ b/.github/workflows/PublishReleaseNotes.yml @@ -505,9 +505,11 @@ jobs: if [[ $? -eq 0 ]]; then if [[ -z "${latestVersion}" ]]; then printf "${ANSI_LIGHT_RED}[UNKNOWN]${ANSI_NOCOLOR}\n" + printf " latest=unknown\n" latestVersion="unknown" else printf "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}\n" + printf " latest=%s\n" "${latestVersion}" fi else printf "${ANSI_LIGHT_RED}[ERROR]${ANSI_NOCOLOR}\n" @@ -529,7 +531,7 @@ jobs: jsonInventory=$(jq -c -n \ --arg structVersion "${STRUCT_VERSION}" \ - --arg date "$(date +"%Y-%m-%dT%H-%M-%S%:z")" \ + --arg date "$(date +"%Y-%m-%dT%H:%M:%S%:z")" \ --argjson jsonMeta "$(jq -c -n \ --arg tag "${{ inputs.tag }}" \ --arg version "${{ inputs.inventory-version }}" \ From 1e694005edd2b8a598f83ad16aa486b95a36258b Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 1 Oct 2025 03:11:48 +0200 Subject: [PATCH 4/5] Fixed structure version datatype in inventory JSON. --- .github/workflows/PublishReleaseNotes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PublishReleaseNotes.yml b/.github/workflows/PublishReleaseNotes.yml index 36c090a..4fb926e 100644 --- a/.github/workflows/PublishReleaseNotes.yml +++ b/.github/workflows/PublishReleaseNotes.yml @@ -549,7 +549,7 @@ jobs: )" \ '{"tag": $tag, "version": $version, "git-hash": $hash, "repository-url": $repo, "release-url": $release, "categories": $categories, "latest": $jsonLatest}' \ )" \ - '{"version": $structVersion, "timestamp": $date, "meta": $jsonMeta, "files": {}}' + '{"version": "$structVersion", "timestamp": $date, "meta": $jsonMeta, "files": {}}' ) fi From 5b97eaf241d1ff491b2919139b947e6269969a5f Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 1 Oct 2025 12:55:33 +0200 Subject: [PATCH 5/5] Gather a list of submodule names, pathes etc. --- .github/workflows/PrepareJob.yml | 72 ++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/.github/workflows/PrepareJob.yml b/.github/workflows/PrepareJob.yml index ab44762..1cbdbf3 100644 --- a/.github/workflows/PrepareJob.yml +++ b/.github/workflows/PrepareJob.yml @@ -62,6 +62,9 @@ on: is_release_tag: description: "" value: ${{ jobs.Prepare.outputs.is_release_tag }} + has_submodules: + description: "" + value: ${{ jobs.Prepare.outputs.has_submodules }} ref_kind: description: "" value: ${{ jobs.Prepare.outputs.ref_kind }} @@ -89,29 +92,42 @@ on: # pr_mergedat: # description: "" # value: ${{ jobs.Prepare.outputs.pr_mergedat }} + git_submodule_count: + description: "" + value: ${{ jobs.Prepare.outputs.git_submodule_count }} + git_submodule_names: + description: "" + value: ${{ jobs.Prepare.outputs.git_submodule_names }} + git_submodule_paths: + description: "" + value: ${{ jobs.Prepare.outputs.git_submodule_paths }} jobs: Prepare: name: Extract Information runs-on: ubuntu-24.04 outputs: - on_default_branch: ${{ steps.Classify.outputs.on_default_branch }} - on_main_branch: ${{ steps.Classify.outputs.on_main_branch }} - on_release_branch: ${{ steps.Classify.outputs.on_release_branch }} - on_dev_branch: ${{ steps.Classify.outputs.on_dev_branch }} - is_regular_commit: ${{ steps.Classify.outputs.is_regular_commit }} - is_merge_commit: ${{ steps.Classify.outputs.is_merge_commit }} - is_release_commit: ${{ steps.Classify.outputs.is_release_commit }} - is_nightly_tag: ${{ steps.Classify.outputs.is_nightly_tag }} - is_release_tag: ${{ steps.Classify.outputs.is_release_tag }} - ref_kind: ${{ steps.Classify.outputs.ref_kind }} - default_branch: ${{ steps.Classify.outputs.default_branch }} - branch: ${{ steps.Classify.outputs.branch }} - tag: ${{ steps.Classify.outputs.tag }} - version: ${{ steps.Classify.outputs.version || steps.FindPullRequest.outputs.pr_version }} -# release_version: ${{ steps.FindPullRequest.outputs.release_version }} - pr_title: ${{ steps.FindPullRequest.outputs.pr_title }} - pr_number: ${{ steps.Classify.outputs.pr_number || steps.FindPullRequest.outputs.pr_number }} + on_default_branch: ${{ steps.Classify.outputs.on_default_branch }} + on_main_branch: ${{ steps.Classify.outputs.on_main_branch }} + on_release_branch: ${{ steps.Classify.outputs.on_release_branch }} + on_dev_branch: ${{ steps.Classify.outputs.on_dev_branch }} + is_regular_commit: ${{ steps.Classify.outputs.is_regular_commit }} + is_merge_commit: ${{ steps.Classify.outputs.is_merge_commit }} + is_release_commit: ${{ steps.Classify.outputs.is_release_commit }} + is_nightly_tag: ${{ steps.Classify.outputs.is_nightly_tag }} + is_release_tag: ${{ steps.Classify.outputs.is_release_tag }} + has_submodules: ${{ steps.Classify.outputs.has_submodules }} + ref_kind: ${{ steps.Classify.outputs.ref_kind }} + default_branch: ${{ steps.Classify.outputs.default_branch }} + branch: ${{ steps.Classify.outputs.branch }} + tag: ${{ steps.Classify.outputs.tag }} + version: ${{ steps.Classify.outputs.version || steps.FindPullRequest.outputs.pr_version }} +# release_version: ${{ steps.FindPullRequest.outputs.release_version }} + pr_title: ${{ steps.FindPullRequest.outputs.pr_title }} + pr_number: ${{ steps.Classify.outputs.pr_number || steps.FindPullRequest.outputs.pr_number }} + git_submodule_count: ${{ steps.Classify.outputs.git_submodule_count }} + git_submodule_names: ${{ steps.Classify.outputs.git_submodule_names }} + git_submodule_paths: ${{ steps.Classify.outputs.git_submodule_paths }} steps: - name: ⏬ Checkout repository @@ -152,12 +168,16 @@ jobs: is_release_commit="false" is_nightly_tag="false" is_release_tag="false" + has_submodules="false" ref_kind="unknown" default_branch="" branch="" tag="" pr_number="" version="" + git_submodule_count="0" + git_submodule_names="" + git_submodule_paths="" printf "Classify Git reference '%s' " "${ref}" if [[ "${ref:0:11}" == "refs/heads/" ]]; then @@ -272,6 +292,15 @@ jobs: exit 1 fi + # Submodules + if [[ -f .gitsubmodules ]]; then + has_submodules="true" + git_modules_file=.gitmodules # $(git rev-parse --show-toplevel)/.gitmodules + git_submodule_count="$(grep -Po '(?<=\[submodule \")(.*)(?=\"\])' "${git_modules_file}" | wc -l)" + git_submodule_names="$(grep -Po '(?<=\[submodule \")(.*)(?=\"\])' "${git_modules_file}" | paste -sd ':' -)" + git_submodule_paths="$(git config --file "${git_modules_file}" --null --name-only --get-regexp '\.path$' | xargs -0 -n1 git config --file "${git_modules_file}" --get | paste -sd ':' -)" + fi + printf "\nWriting output variables ...\n" tee --append "${GITHUB_OUTPUT}" <