From 8fd0f0d7183a9e5e9c82a511be5253763245b963 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 03:46:39 +0300 Subject: [PATCH 01/33] Make workflows re-usable --- .github/workflows/createchangelog.yml | 5 ++-- .github/workflows/github-pages.yml | 36 +++++++++++++++++---------- .github/workflows/pre-release.yaml | 5 +++- .github/workflows/release.yaml | 6 ++++- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/.github/workflows/createchangelog.yml b/.github/workflows/createchangelog.yml index 6251f9a5a6..96d51d219e 100644 --- a/.github/workflows/createchangelog.yml +++ b/.github/workflows/createchangelog.yml @@ -1,9 +1,8 @@ name: Update changelog.md on Release on: - release: - types: [published, created, edited, deleted] - workflow_dispatch: # Add this line to enable manual triggering + workflow_dispatch: # Manual trigger added + workflow_call: # Make this Working a re-usable one (can be called form another workflow) jobs: update-file: diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 486d1ed96f..3d96db2b31 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -1,22 +1,32 @@ name: GitHub Pages Deploy on: - release: - types: [published, prereleased] - workflow_dispatch: + workflow_dispatch: # Manual trigger added + workflow_call: # Make this Working a re-usable one (can be called form another workflow) + permissions: contents: write + jobs: - deploy: + call_createchangelog: + uses: ./.github/workflows/createchangelog.yaml + + build_and_deploy: + needs: call_createchangelog runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 with: python-version: 3.x - - uses: actions/cache@v4 - with: - key: ${{ github.ref }} - path: .cache - - run: pip install mkdocs-material - - run: pip install pillow cairosvg - - run: mkdocs gh-deploy --force + + - name: Install Additional Python Dependencies + run: | + pip install mkdocs-material + pip install pillow cairosvg + + - name: Build using MkDocs & Deploy to GitHub Pages + run: mkdocs gh-deploy --force diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 34e04d3210..07430d9763 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -8,7 +8,10 @@ on: workflow_dispatch: # Manual trigger added jobs: - build-runspace: + call_github_pages_workflow: + uses: ./.github/workflows/github-pages.yaml + + release_winutil_as_prerelease: runs-on: windows-latest steps: - name: Checkout Repository diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index df5f3d5d74..8d751ba821 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,10 +4,11 @@ on: workflow_dispatch: # Manual trigger added jobs: - build-runspace: + release_winutil: runs-on: windows-latest outputs: version: ${{ steps.extract_version.outputs.version }} + steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -42,3 +43,6 @@ jobs: make_latest: "true" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + call_github_pages: + uses: ./.github/workflows/github_pages.yaml From 0a1e4cc512b26aaa4aac2e27f4008cfbdc9d26d9 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 03:53:23 +0300 Subject: [PATCH 02/33] Rename File Extensions for some workflow files --- .github/workflows/{close-discussion.yml => close-discussion.yaml} | 0 .github/workflows/{createchangelog.yml => createchangelog.yaml} | 0 .github/workflows/{github-pages.yml => github-pages.yaml} | 0 .github/workflows/{sponsors.yml => sponsors.yaml} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{close-discussion.yml => close-discussion.yaml} (100%) rename .github/workflows/{createchangelog.yml => createchangelog.yaml} (100%) rename .github/workflows/{github-pages.yml => github-pages.yaml} (100%) rename .github/workflows/{sponsors.yml => sponsors.yaml} (100%) diff --git a/.github/workflows/close-discussion.yml b/.github/workflows/close-discussion.yaml similarity index 100% rename from .github/workflows/close-discussion.yml rename to .github/workflows/close-discussion.yaml diff --git a/.github/workflows/createchangelog.yml b/.github/workflows/createchangelog.yaml similarity index 100% rename from .github/workflows/createchangelog.yml rename to .github/workflows/createchangelog.yaml diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yaml similarity index 100% rename from .github/workflows/github-pages.yml rename to .github/workflows/github-pages.yaml diff --git a/.github/workflows/sponsors.yml b/.github/workflows/sponsors.yaml similarity index 100% rename from .github/workflows/sponsors.yml rename to .github/workflows/sponsors.yaml From 7ee15a79cec88ea68cccb11cadefb5bb75832016 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 04:04:33 +0300 Subject: [PATCH 03/33] Change job ordering --- .github/workflows/createchangelog.yaml | 2 +- .github/workflows/pre-release.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 96d51d219e..af40d00f5a 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -5,7 +5,7 @@ on: workflow_call: # Make this Working a re-usable one (can be called form another workflow) jobs: - update-file: + update-changelog-file: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 07430d9763..de5e3af53d 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -8,9 +8,6 @@ on: workflow_dispatch: # Manual trigger added jobs: - call_github_pages_workflow: - uses: ./.github/workflows/github-pages.yaml - release_winutil_as_prerelease: runs-on: windows-latest steps: @@ -49,3 +46,6 @@ jobs: generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + call_github_pages_workflow: + uses: ./.github/workflows/github-pages.yaml From c6613dedc3e8c137b68309a41575defa60614aab Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 04:09:28 +0300 Subject: [PATCH 04/33] Try something else to force specific job ordering --- .github/workflows/pre-release.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index de5e3af53d..d4e1aeecaa 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -8,7 +8,11 @@ on: workflow_dispatch: # Manual trigger added jobs: + call_github_pages_workflow: + uses: ./.github/workflows/github-pages.yaml + release_winutil_as_prerelease: + needs: call_github_pages_workflow runs-on: windows-latest steps: - name: Checkout Repository @@ -46,6 +50,3 @@ jobs: generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - call_github_pages_workflow: - uses: ./.github/workflows/github-pages.yaml From b0c2165e1f7532556f8afa9af113182690c17c19 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 04:12:49 +0300 Subject: [PATCH 05/33] Another Try something else to force specific job ordering --- .github/workflows/pre-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index d4e1aeecaa..6b5114b66a 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -9,10 +9,10 @@ on: jobs: call_github_pages_workflow: + needs: release_winutil_as_prerelease uses: ./.github/workflows/github-pages.yaml release_winutil_as_prerelease: - needs: call_github_pages_workflow runs-on: windows-latest steps: - name: Checkout Repository From 05f75c9302819547631a664402c681f0cf0be91a Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 07:57:58 +0300 Subject: [PATCH 06/33] Add comments & rename some jobs --- .github/workflows/github-pages.yaml | 7 ++++--- .github/workflows/pre-release.yaml | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml index 3d96db2b31..5df2e25c0f 100644 --- a/.github/workflows/github-pages.yaml +++ b/.github/workflows/github-pages.yaml @@ -7,11 +7,12 @@ permissions: contents: write jobs: - call_createchangelog: + update-changelog: uses: ./.github/workflows/createchangelog.yaml - build_and_deploy: - needs: call_createchangelog + bulid-deploy-gh-pages: + # Make sure 'update-changelog' run first, then run this job afterward + needs: update-changelog runs-on: ubuntu-latest steps: diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 6b5114b66a..26125a0317 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -8,11 +8,7 @@ on: workflow_dispatch: # Manual trigger added jobs: - call_github_pages_workflow: - needs: release_winutil_as_prerelease - uses: ./.github/workflows/github-pages.yaml - - release_winutil_as_prerelease: + release: runs-on: windows-latest steps: - name: Checkout Repository @@ -50,3 +46,8 @@ jobs: generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + deploy-github-pages: + # Make sure 'release' job runs first, then run this job afterward + needs: release + uses: ./.github/workflows/github-pages.yaml From 85d56fb973a042c02821cf41943338de63abf7ec Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 07:59:59 +0300 Subject: [PATCH 07/33] Make 'github-pages' workflow file get latest commits from action's current branch Current branch means the running git branch that the GitHub Action was ran at. --- .github/workflows/github-pages.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml index 5df2e25c0f..01519f32f0 100644 --- a/.github/workflows/github-pages.yaml +++ b/.github/workflows/github-pages.yaml @@ -18,6 +18,9 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v4 + # Make sure to get latest commits, like the one committed by the previous job in jobs list. + with: + ref: ${{ github.ref_name }} - name: Setup Python uses: actions/setup-python@v4 From a8f17ceac8ff8e529ac08cead7a6a6831ff86010 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 08:31:25 +0300 Subject: [PATCH 08/33] Add reference to 'Checkout Repo' step --- .github/workflows/github-pages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml index 01519f32f0..ef063cd468 100644 --- a/.github/workflows/github-pages.yaml +++ b/.github/workflows/github-pages.yaml @@ -19,6 +19,7 @@ jobs: - name: Checkout Repo uses: actions/checkout@v4 # Make sure to get latest commits, like the one committed by the previous job in jobs list. + # reference: https://github.com/orgs/community/discussions/110853 with: ref: ${{ github.ref_name }} From 2bda652391290735fb9579e857107cfb39fa45e7 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 08:33:31 +0300 Subject: [PATCH 09/33] Fix Admonition in Changelog Workflow --- .github/workflows/createchangelog.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index af40d00f5a..6f6430578c 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -25,10 +25,11 @@ jobs: # Write some Initial Content to changelog file echo "# Changelog" >> $changelog_path echo "" >> $changelog_path - echo "WinUtil change log received from GitHub Releases, it's autogenerated using GitHub Actions." >> $changelog_path + echo "WinUtil changelog is based on GitHub Releases, and autogenerated using GitHub Actions." >> $changelog_path echo "" >> $changelog_path - echo "> [!WARNING]" >> $changelog_path - echo "> This file **SHOULD NOT** be edited directly, any PRs that tries changing it directly will either be requested on not changing it, or it'll get rejected." >> $changelog_path + echo "!!! warning" >> $changelog_path + echo "" >> $changelog_path + echo "This file **SHOULD NOT** be edited directly, any PRs that tries changing it directly will either be requested on not changing it, or said PR **will get rejected**." >> $changelog_path echo "" >> $changelog_path # Make array for git tag names From a6bc7ca4031def0a1ceea963bcc5e0a45bf06f3a Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 08:37:16 +0300 Subject: [PATCH 10/33] Remove un-used 'release.yaml' workflow --- .github/workflows/release.yaml | 48 ---------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 8d751ba821..0000000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: Release WinUtil - -on: - workflow_dispatch: # Manual trigger added - -jobs: - release_winutil: - runs-on: windows-latest - outputs: - version: ${{ steps.extract_version.outputs.version }} - - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Extract Version from winutil.ps1 - id: extract_version - run: | - $version = '' - Get-Content ./winutil.ps1 -TotalCount 30 | ForEach-Object { - if ($_ -match 'Version\s*:\s*(\d{2}\.\d{2}\.\d{2})') { - $version = $matches[1] - echo "version=$version" >> $GITHUB_OUTPUT - break - } - } - if (-not $version) { - Write-Error "Version not found in winutil.ps1" - exit 1 - } - shell: pwsh - - - name: Create and Upload Release - id: create_release - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ steps.extract_version.outputs.version }} - name: Release ${{ steps.extract_version.outputs.version }} - body: "![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/winutil/${{ steps.extract_version.outputs.version }}/winutil.ps1)" - append_body: true - files: ./winutil.ps1 - prerelease: false - make_latest: "true" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - call_github_pages: - uses: ./.github/workflows/github_pages.yaml From d923e34a3e6b6103c0501fc5e386a44bd0ab7e57 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 08:54:39 +0300 Subject: [PATCH 11/33] Add 'release' event to 'github-pages' workflow --- .github/workflows/github-pages.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml index ef063cd468..19d06817f2 100644 --- a/.github/workflows/github-pages.yaml +++ b/.github/workflows/github-pages.yaml @@ -1,5 +1,7 @@ name: GitHub Pages Deploy on: + release: + types: [edited, deleted] # Make sure changelog is up-to-date by updating it, and building GitHub Pages. workflow_dispatch: # Manual trigger added workflow_call: # Make this Working a re-usable one (can be called form another workflow) From 2d95b12e8fdee0135f2a3149aa04735d724f1df0 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 09:02:00 +0300 Subject: [PATCH 12/33] Fix Admonition in Changelog Workflow --- .github/workflows/createchangelog.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 6f6430578c..d40962190b 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -27,9 +27,9 @@ jobs: echo "" >> $changelog_path echo "WinUtil changelog is based on GitHub Releases, and autogenerated using GitHub Actions." >> $changelog_path echo "" >> $changelog_path - echo "!!! warning" >> $changelog_path + echo "!!! warning \"Important\"" >> $changelog_path echo "" >> $changelog_path - echo "This file **SHOULD NOT** be edited directly, any PRs that tries changing it directly will either be requested on not changing it, or said PR **will get rejected**." >> $changelog_path + echo " This file **SHOULD NOT** be edited directly, any PRs that tries changing it directly will either be requested on not changing it, or said PR **will get rejected**." >> $changelog_path echo "" >> $changelog_path # Make array for git tag names From 11658a63bcbe6f80cd521448e3a8fa7cc4caa411 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 21:29:11 +0300 Subject: [PATCH 13/33] Make 'actions/checkout' fetch latest of anything, git submodules, tags, and commits --- .github/workflows/createchangelog.yaml | 6 ++++++ .github/workflows/github-pages.yaml | 2 ++ .github/workflows/pre-release.yaml | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index d40962190b..87e27206bd 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -11,6 +11,12 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + # Make sure to get latest commits, like the one committed by the previous job in jobs list. + # reference: https://github.com/orgs/community/discussions/110853 + with: + fetch-tags: 'true' + submodules: 'recursive' + ref: ${{ github.ref_name }} - name: Get all releases and update changelog.md file run: | diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml index 19d06817f2..52709063e4 100644 --- a/.github/workflows/github-pages.yaml +++ b/.github/workflows/github-pages.yaml @@ -23,6 +23,8 @@ jobs: # Make sure to get latest commits, like the one committed by the previous job in jobs list. # reference: https://github.com/orgs/community/discussions/110853 with: + fetch-tags: 'true' + submodules: 'recursive' ref: ${{ github.ref_name }} - name: Setup Python diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 26125a0317..eb4cb3951f 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -13,6 +13,12 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + # Make sure to get latest commits, like the one committed by the previous job in jobs list. + # reference: https://github.com/orgs/community/discussions/110853 + with: + fetch-tags: 'true' + submodules: 'recursive' + ref: ${{ github.ref_name }} - name: Extract Version from winutil.ps1 id: extract_version From 6c5c86914e136f033cda4d8267f22505a93300d8 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 21:39:02 +0300 Subject: [PATCH 14/33] Fix yaml syntax error --- .github/workflows/createchangelog.yaml | 198 ++++++++++++------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 87e27206bd..111bb5b680 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -9,8 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v4 + - name: Checkout Repository + uses: actions/checkout@v4 # Make sure to get latest commits, like the one committed by the previous job in jobs list. # reference: https://github.com/orgs/community/discussions/110853 with: @@ -18,102 +18,102 @@ jobs: submodules: 'recursive' ref: ${{ github.ref_name }} - - name: Get all releases and update changelog.md file - run: | - # Initialize some values - changelog_path="docs/changelog.md" - gh release list --exclude-drafts --json tagName,name,isLatest,isPrerelease --limit 1000000 > releases.txt - declare -rA number_of_releases=$(cat releases.txt | grep -Po '"tagName"' | wc --lines) - - # Clear the contents of changelog file - echo "" > $changelog_path - - # Write some Initial Content to changelog file - echo "# Changelog" >> $changelog_path - echo "" >> $changelog_path - echo "WinUtil changelog is based on GitHub Releases, and autogenerated using GitHub Actions." >> $changelog_path - echo "" >> $changelog_path - echo "!!! warning \"Important\"" >> $changelog_path - echo "" >> $changelog_path - echo " This file **SHOULD NOT** be edited directly, any PRs that tries changing it directly will either be requested on not changing it, or said PR **will get rejected**." >> $changelog_path - echo "" >> $changelog_path - - # Make array for git tag names - tag_arr=() - cat releases.txt | grep -Po '"tagName":\s*.*?[^\\]"' | awk -F ':' '{print $2}' | sed s/\"//g > tags_list.txt - while read -r line; do - tag_arr+=("$line") - done < tags_list.txt - - # Make array for releases names - name_arr=() - cat releases.txt | grep -Po '"name":\s*.*?[^\\]"' | awk -F ':' '{print $2}' | sed s/\"//g > releases_names_list.txt - while read -r line; do - name_arr+=("$line") - done < releases_names_list.txt - - # Make array for isPrerelease - isprerelease_arr=() - cat releases.txt | grep -Po '"isPrerelease":\s*(false|true)' | awk -F ':' '{print $2}' | sed s/\"//g > isprerelease_list.txt - while read -r line; do - isprerelease_arr+=("$line") - done < isprerelease_list.txt - - # Make array for isLatest - islatest_arr=() - cat releases.txt | grep -Po '"isLatest":\s*(false|true)' | awk -F ':' '{print $2}' | sed s/\"//g > islatest_list.txt - while read -r line; do - islatest_arr+=("$line") - done < islatest_list.txt - - # Debug Output - echo "Tag Array: " ${tag_arr[@]} - echo "Array Length: " ${#tag_arr[@]} - echo "" - - echo "Release Name Array: " ${name_arr[@]} - echo "Array Length: " ${#name_arr[@]} - echo "" - - echo "IsPrerelease Array: " ${isprerelease_arr[@]} - echo "Array Length: " ${#isprerelease_arr[@]} - echo "" - - echo "IsLatest Array: " ${islatest_arr[@]} - echo "Array Length: " ${#islatest_arr[@]} - echo "" - - # Exit when this impossible condition is met (just to be safe) - if [[ ! (${#tag_arr[@]}==${#name_arr[@]} && ${#tag_arr[@]}==${#isprerelease_arr[@]} && ${#tag_arr[@]}==${#islatest_arr[@]} ) ]] ; then - echo "Impossible Condition has been met, the Name Array Length Does Not match Tag Array Length, exiting..." - exit 1 - fi - - # Main loop that does the heavy lifting (Content Generation) - for (( i=0; i<${number_of_releases}; i++ )); - do - # The Variables to use on each iteration - tag=${tag_arr[$i]} - name=${name_arr[$i]} - isprerelease=${isprerelease_arr[$i]} - islatest=${islatest_arr[$i]} - body=$(gh release view "$tag" --json body --jq .body) - - # The generation of changelog file contents - echo "# $name" >> $changelog_path + - name: Get all releases and update changelog.md file + run: | + # Initialize some values + changelog_path="docs/changelog.md" + gh release list --exclude-drafts --json tagName,name,isLatest,isPrerelease --limit 1000000 > releases.txt + declare -rA number_of_releases=$(cat releases.txt | grep -Po '"tagName"' | wc --lines) + + # Clear the contents of changelog file + echo "" > $changelog_path + + # Write some Initial Content to changelog file + echo "# Changelog" >> $changelog_path + echo "" >> $changelog_path + echo "WinUtil changelog is based on GitHub Releases, and autogenerated using GitHub Actions." >> $changelog_path echo "" >> $changelog_path - echo "$body" >> $changelog_path + echo "!!! warning \"Important\"" >> $changelog_path echo "" >> $changelog_path - done - env: - GH_TOKEN: ${{ github.token }} - - - name: Commit and Push Changes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git add docs/changelog.md - git commit -m "Update changelog.md with all releases" - git push + echo " This file **SHOULD NOT** be edited directly, any PRs that tries changing it directly will either be requested on not changing it, or said PR **will get rejected**." >> $changelog_path + echo "" >> $changelog_path + + # Make array for git tag names + tag_arr=() + cat releases.txt | grep -Po '"tagName":\s*.*?[^\\]"' | awk -F ':' '{print $2}' | sed s/\"//g > tags_list.txt + while read -r line; do + tag_arr+=("$line") + done < tags_list.txt + + # Make array for releases names + name_arr=() + cat releases.txt | grep -Po '"name":\s*.*?[^\\]"' | awk -F ':' '{print $2}' | sed s/\"//g > releases_names_list.txt + while read -r line; do + name_arr+=("$line") + done < releases_names_list.txt + + # Make array for isPrerelease + isprerelease_arr=() + cat releases.txt | grep -Po '"isPrerelease":\s*(false|true)' | awk -F ':' '{print $2}' | sed s/\"//g > isprerelease_list.txt + while read -r line; do + isprerelease_arr+=("$line") + done < isprerelease_list.txt + + # Make array for isLatest + islatest_arr=() + cat releases.txt | grep -Po '"isLatest":\s*(false|true)' | awk -F ':' '{print $2}' | sed s/\"//g > islatest_list.txt + while read -r line; do + islatest_arr+=("$line") + done < islatest_list.txt + + # Debug Output + echo "Tag Array: " ${tag_arr[@]} + echo "Array Length: " ${#tag_arr[@]} + echo "" + + echo "Release Name Array: " ${name_arr[@]} + echo "Array Length: " ${#name_arr[@]} + echo "" + + echo "IsPrerelease Array: " ${isprerelease_arr[@]} + echo "Array Length: " ${#isprerelease_arr[@]} + echo "" + + echo "IsLatest Array: " ${islatest_arr[@]} + echo "Array Length: " ${#islatest_arr[@]} + echo "" + + # Exit when this impossible condition is met (just to be safe) + if [[ ! (${#tag_arr[@]}==${#name_arr[@]} && ${#tag_arr[@]}==${#isprerelease_arr[@]} && ${#tag_arr[@]}==${#islatest_arr[@]} ) ]] ; then + echo "Impossible Condition has been met, the Name Array Length Does Not match Tag Array Length, exiting..." + exit 1 + fi + + # Main loop that does the heavy lifting (Content Generation) + for (( i=0; i<${number_of_releases}; i++ )); + do + # The Variables to use on each iteration + tag=${tag_arr[$i]} + name=${name_arr[$i]} + isprerelease=${isprerelease_arr[$i]} + islatest=${islatest_arr[$i]} + body=$(gh release view "$tag" --json body --jq .body) + + # The generation of changelog file contents + echo "# $name" >> $changelog_path + echo "" >> $changelog_path + echo "$body" >> $changelog_path + echo "" >> $changelog_path + done + env: + GH_TOKEN: ${{ github.token }} + + - name: Commit and Push Changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add docs/changelog.md + git commit -m "Update changelog.md with all releases" + git push From 753d9f95ccb508fce75a862a50314145375502a2 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 21:58:52 +0300 Subject: [PATCH 15/33] Handle special case in 'createchangelog.yaml' workflow --- .github/workflows/createchangelog.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 111bb5b680..e030286dc4 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -116,4 +116,9 @@ jobs: git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add docs/changelog.md git commit -m "Update changelog.md with all releases" - git push + echo "Event name: ${{ github.event_name }}" + if ['${{ github.event_name }}' = 'release']; then + git push --force + else + git push + fi From c63c9aa984af282898d1b3fc89f1b69ee89fb683 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sun, 28 Jul 2024 22:30:38 +0300 Subject: [PATCH 16/33] Update workflows --- .github/workflows/createchangelog.yaml | 6 +++++- .github/workflows/github-pages.yaml | 2 +- .github/workflows/pre-release.yaml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index e030286dc4..52a47d1920 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -16,7 +16,7 @@ jobs: with: fetch-tags: 'true' submodules: 'recursive' - ref: ${{ github.ref_name }} + ref: ${{ github.ref }} - name: Get all releases and update changelog.md file run: | @@ -112,6 +112,10 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + if ['${{ github.event_name }}' = 'release']; then + git branch --contains ${{ github.ref }} | grep -Po '\*\s*.*' | sed 's/\* //g' > branch_name.txt + fi + cat branch_name.txt git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add docs/changelog.md diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml index 52709063e4..b20297ebca 100644 --- a/.github/workflows/github-pages.yaml +++ b/.github/workflows/github-pages.yaml @@ -25,7 +25,7 @@ jobs: with: fetch-tags: 'true' submodules: 'recursive' - ref: ${{ github.ref_name }} + ref: ${{ github.ref }} - name: Setup Python uses: actions/setup-python@v4 diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index eb4cb3951f..5edc1a6c0e 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -18,7 +18,7 @@ jobs: with: fetch-tags: 'true' submodules: 'recursive' - ref: ${{ github.ref_name }} + ref: ${{ github.ref }} - name: Extract Version from winutil.ps1 id: extract_version From 0d12b0c8773f7e3fca4cbda74ac0939eea0a51d6 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 05:15:57 +0300 Subject: [PATCH 17/33] Fix issue with 'createchangelog' workflow always switching to Git Detached Head Mode --- .github/workflows/createchangelog.yaml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 52a47d1920..f9726834fb 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -18,6 +18,20 @@ jobs: submodules: 'recursive' ref: ${{ github.ref }} + - name: Get correct branch to use for committing changes + id: get_correct_branch + run: | + # NOTE/TODO: + # Because there's a chance where this'll get triggered by a Release Creation, Edit, Deletion.. + # the value of 'github.ref' will be 'refs/tags/TAG-NAME', and this tag can not be handled easily by + # the 'actions/checkout' action.. we need to handle this case by always changing to main branch. + declare -rA number_of_refname_instances=$(git branch -a | grep -Po '${{ github.ref_name }}' | wc --lines) + if [[ $number_of_refname_instances = 0 ]] ; then + echo "branch_name=main" >> $GITHUB_OUTPUT + else + echo "branch_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT + fi + - name: Get all releases and update changelog.md file run: | # Initialize some values @@ -112,17 +126,11 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - if ['${{ github.event_name }}' = 'release']; then - git branch --contains ${{ github.ref }} | grep -Po '\*\s*.*' | sed 's/\* //g' > branch_name.txt - fi - cat branch_name.txt git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git switch ${{ steps.get_correct_branch.outputs.branch_name }} + git pull git add docs/changelog.md git commit -m "Update changelog.md with all releases" echo "Event name: ${{ github.event_name }}" - if ['${{ github.event_name }}' = 'release']; then - git push --force - else - git push - fi + git push From feee5188fa8aa6fbe7d42d7d71c782c4f250099b Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 05:40:49 +0300 Subject: [PATCH 18/33] Reorder 'env' field in 'createchangelog' workflow --- .github/workflows/createchangelog.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index f9726834fb..f95a4ff7b7 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -123,8 +123,6 @@ jobs: GH_TOKEN: ${{ github.token }} - name: Commit and Push Changes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' @@ -134,3 +132,5 @@ jobs: git commit -m "Update changelog.md with all releases" echo "Event name: ${{ github.event_name }}" git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1343bd9d36de70f2883652b73562183a2ac9c707 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 05:44:30 +0300 Subject: [PATCH 19/33] Fix 'close-discussion' workflow not working --- .github/workflows/close-discussion.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close-discussion.yaml b/.github/workflows/close-discussion.yaml index 252b7823b2..306134d797 100644 --- a/.github/workflows/close-discussion.yaml +++ b/.github/workflows/close-discussion.yaml @@ -33,6 +33,6 @@ jobs: echo "$discussion_id" curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \ -d '{"state": "closed"}' \ - 'https://api.github.com/repos/${{ github.repository }}/discussions/$discussion_id' + "https://api.github.com/repos/${{ github.repository }}/discussions/$discussion_id" done shell: bash From 5b47a33f90a55e3668465d712cd8178e3acec4d1 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 06:03:15 +0300 Subject: [PATCH 20/33] Add debug info to 'close-discussion' workflow --- .github/workflows/close-discussion.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/close-discussion.yaml b/.github/workflows/close-discussion.yaml index 306134d797..a0ef0fd5fd 100644 --- a/.github/workflows/close-discussion.yaml +++ b/.github/workflows/close-discussion.yaml @@ -27,8 +27,13 @@ jobs: done < discussion_ids_list.txt number_of_ids=${#discussion_ids_arr[@]} - for (( i=0; i<${number_of_ids}; i++ )); - do + + echo "Number of IDs: ${number_of_ids}" + echo "IDs Array: ${discussion_ids_arr[@]}" + echo "IDs List:" + cat discussion_ids_list.txt + + for (( i=0; i<${number_of_ids}; i++ )); do discussion_id=${discussion_ids_arr[$i]} echo "$discussion_id" curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \ From 416ab767155c2c7a40876b6af99d9d00441467c3 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 10:01:25 +0300 Subject: [PATCH 21/33] Bring back control to the 'Extract Discussion Number & Close If any Where Found' step in 'close-discussion' workflow --- .github/workflows/close-discussion.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/close-discussion.yaml b/.github/workflows/close-discussion.yaml index a0ef0fd5fd..28d982a1e4 100644 --- a/.github/workflows/close-discussion.yaml +++ b/.github/workflows/close-discussion.yaml @@ -13,6 +13,12 @@ jobs: run: echo "PR was merged" - name: Extract Discussion Number & Close If any Where Found + # Make the running bash script behave like it would when ran locally + # by default GitHub actions has 'set -e', which'll make the whole step fail + # upon small things, like grep not finding any matches.. which sometimes + # we do want this behavior, so we set shell to be 'bash {0}' to bring back control. + # reference: https://stackoverflow.com/questions/73066461/github-actions-why-an-intermediate-command-failure-in-shell-script-would-cause + shell: bash {0} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: github.event.pull_request.merged == true @@ -40,4 +46,3 @@ jobs: -d '{"state": "closed"}' \ "https://api.github.com/repos/${{ github.repository }}/discussions/$discussion_id" done - shell: bash From fb4de0f928ec55694b397ed394f4a4810eb53c78 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 10:30:35 +0300 Subject: [PATCH 22/33] Make 'grep' treat git ref as a simple string rather than a pattern (regex) --- .github/workflows/createchangelog.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index f95a4ff7b7..ecfe68c45f 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -25,7 +25,7 @@ jobs: # Because there's a chance where this'll get triggered by a Release Creation, Edit, Deletion.. # the value of 'github.ref' will be 'refs/tags/TAG-NAME', and this tag can not be handled easily by # the 'actions/checkout' action.. we need to handle this case by always changing to main branch. - declare -rA number_of_refname_instances=$(git branch -a | grep -Po '${{ github.ref_name }}' | wc --lines) + declare -rA number_of_refname_instances=$(git branch -a | grep -F '${{ github.ref_name }}' | wc --lines) if [[ $number_of_refname_instances = 0 ]] ; then echo "branch_name=main" >> $GITHUB_OUTPUT else From 431533d3dd49629c09ff8e6fb0181bf341112099 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 10:42:55 +0300 Subject: [PATCH 23/33] Better filter the results in second step of 'createchangelog' workflow --- .github/workflows/createchangelog.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index ecfe68c45f..661ebdf07b 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -25,7 +25,7 @@ jobs: # Because there's a chance where this'll get triggered by a Release Creation, Edit, Deletion.. # the value of 'github.ref' will be 'refs/tags/TAG-NAME', and this tag can not be handled easily by # the 'actions/checkout' action.. we need to handle this case by always changing to main branch. - declare -rA number_of_refname_instances=$(git branch -a | grep -F '${{ github.ref_name }}' | wc --lines) + declare -rA number_of_refname_instances=$(git branch -a | grep -F '${{ github.ref_name }}' | grep -i -v -e 'HEAD\s*detached' | wc --lines) if [[ $number_of_refname_instances = 0 ]] ; then echo "branch_name=main" >> $GITHUB_OUTPUT else From 51e13fa022e3b595ae510f4834a972655ad59a42 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 10:53:16 +0300 Subject: [PATCH 24/33] Another Try to make 'createchangelog' work on release edit/deletion --- .github/workflows/createchangelog.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 661ebdf07b..5cb6cc44f2 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -25,12 +25,19 @@ jobs: # Because there's a chance where this'll get triggered by a Release Creation, Edit, Deletion.. # the value of 'github.ref' will be 'refs/tags/TAG-NAME', and this tag can not be handled easily by # the 'actions/checkout' action.. we need to handle this case by always changing to main branch. + branch_name="" declare -rA number_of_refname_instances=$(git branch -a | grep -F '${{ github.ref_name }}' | grep -i -v -e 'HEAD\s*detached' | wc --lines) if [[ $number_of_refname_instances = 0 ]] ; then - echo "branch_name=main" >> $GITHUB_OUTPUT + branch_name="main" else - echo "branch_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT + branch_name="${{ github.ref_name }}" fi + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git switch $branch_name + git pull + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get all releases and update changelog.md file run: | @@ -124,13 +131,8 @@ jobs: - name: Commit and Push Changes run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git switch ${{ steps.get_correct_branch.outputs.branch_name }} - git pull git add docs/changelog.md git commit -m "Update changelog.md with all releases" - echo "Event name: ${{ github.event_name }}" git push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 03b21a756ea136320a81064e7c2513a2f7177f91 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Wed, 31 Jul 2024 20:43:17 +0300 Subject: [PATCH 25/33] Temporarily make 'close-discussion' as a WIP Workflow See commit patches, or try running this workflow, and see its output. --- .github/workflows/close-discussion.yaml | 58 +++++++++++++------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/.github/workflows/close-discussion.yaml b/.github/workflows/close-discussion.yaml index f27b100cf0..08b7354dbd 100644 --- a/.github/workflows/close-discussion.yaml +++ b/.github/workflows/close-discussion.yaml @@ -27,31 +27,33 @@ jobs: if: github.event.pull_request.merged == true id: extract-discussion run: | - pr_body="${{ github.event.pull_request.body }}" - discussion_ids=$(echo "$pr_body" | grep -oP '(?i)(resolve|fix|close)[s|d]? #\K[0-9]+') - - if [ -z "$discussion_ids" ]; then - echo "No discussion IDs found." - exit 0 - fi - - discussion_ids_arr=() - cat pr_body.txt | grep -i -Po '^\s*(-|\d+\.)?\s*(Resolve(s|d)?)\s*#\d+\s*$|^\s*(-|\d+\.)?\s*(Fix(es|ed)?)\s*#\d+\s*$|^\s*(-|\d+\.)?\s*(Close(s|d)?)\s*#\d+\s*$' | awk -F '#' '{print $2}' > discussion_ids_list.txt - while read -r line; do - discussion_ids_arr+=("$line") - done < discussion_ids_list.txt - - number_of_ids=${#discussion_ids_arr[@]} - - echo "Number of IDs: ${number_of_ids}" - echo "IDs Array: ${discussion_ids_arr[@]}" - echo "IDs List:" - cat discussion_ids_list.txt - - for (( i=0; i<${number_of_ids}; i++ )); do - discussion_id=${discussion_ids_arr[$i]} - echo "$discussion_id" - curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \ - -d '{"state": "closed"}' \ - "https://api.github.com/repos/${{ github.repository }}/discussions/$discussion_id" - done + output_str=$(cat < Date: Thu, 1 Aug 2024 16:19:37 +0300 Subject: [PATCH 26/33] Make http(s) links clickable by converting any links to a format understandable by Markdown - 'createchangelog' Workflow --- .github/workflows/createchangelog.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 5cb6cc44f2..87b5548517 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -126,6 +126,11 @@ jobs: echo "$body" >> $changelog_path echo "" >> $changelog_path done + + # Make http(s) links clickable by converting any links to a format understandable by Markdown + sed -ri 's/(https?:\/\/.*?\/(pull|compare)\/)(.*?)/\[\3\](\1)/g' $changelog_path + sed -ri 's/\[([0-9]+)\]\((https?:\/\/.*?\/pull\/.*?)\)/\[#\1\]\(\2\)/g' $changelog_path + sed -ri 's/@([^ \t\n]+)/[@\1](https:\/\/github\.com\/\1)/g' $changelog_path env: GH_TOKEN: ${{ github.token }} From bb31064661f65aef4c69e763f838e3f160fdfade Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Thu, 1 Aug 2024 16:22:13 +0300 Subject: [PATCH 27/33] Fix YAML syntax error - 'close-discussion' Workflow --- .github/workflows/close-discussion.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close-discussion.yaml b/.github/workflows/close-discussion.yaml index 08b7354dbd..3608838053 100644 --- a/.github/workflows/close-discussion.yaml +++ b/.github/workflows/close-discussion.yaml @@ -36,7 +36,7 @@ jobs: - https://github.com/orgs/community/discussions/43 - https://github.com/orgs/community/discussions/43#discussioncomment-399047 - https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions -DELIMITER) + DELIMITER) echo "$output_str" exit 1 #pr_body="${{ github.event.pull_request.body }}" From a00ac0e1a831fa1a6493286b23d3163cb92fcfc7 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Thu, 1 Aug 2024 16:37:39 +0300 Subject: [PATCH 28/33] Fix RegEx with 'sed' commands - 'createchangelog' Workflow --- .github/workflows/createchangelog.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 87b5548517..2064817bd4 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -128,8 +128,8 @@ jobs: done # Make http(s) links clickable by converting any links to a format understandable by Markdown - sed -ri 's/(https?:\/\/.*?\/(pull|compare)\/)(.*?)/\[\3\](\1)/g' $changelog_path - sed -ri 's/\[([0-9]+)\]\((https?:\/\/.*?\/pull\/.*?)\)/\[#\1\]\(\2\)/g' $changelog_path + sed -ri 's/(https?:\/\/.*?\/(pull|compare)\/(.*?[ \t\r\n]))/\[\3\](\1)/g' $changelog_path + sed -ri 's/\[([0-9]+)\]\((https?:\/\/.*?\/pull\/.*?[ \t\r\n])\)/\[#\1\]\(\2\)/g' $changelog_path sed -ri 's/@([^ \t\n]+)/[@\1](https:\/\/github\.com\/\1)/g' $changelog_path env: GH_TOKEN: ${{ github.token }} From 1982579133784756600bccbca3eb21543bed3ba3 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Thu, 1 Aug 2024 16:38:11 +0300 Subject: [PATCH 29/33] Fix Download Counter for each pre-release - 'pre-release' Workflow --- .github/workflows/pre-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 81b51518dc..d3d37b89de 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -53,7 +53,7 @@ jobs: with: tag_name: ${{ env.VERSION }} name: Pre-Release ${{ env.VERSION }} - body: "![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/winutil/${{ env.VERSION }}/winutil.ps1)" + body: "![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/${{ github.repository }}/${{ env.VERSION }}/winutil.ps1)" append_body: false files: ./winutil.ps1 prerelease: true From 0e2647dad123beab302e36ea5341289608cc5547 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Thu, 1 Aug 2024 16:51:32 +0300 Subject: [PATCH 30/33] Another Fix for 'sed' commands RegEx - 'createchangelog' Workflow --- .github/workflows/createchangelog.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 2064817bd4..976113fe3a 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -128,9 +128,9 @@ jobs: done # Make http(s) links clickable by converting any links to a format understandable by Markdown - sed -ri 's/(https?:\/\/.*?\/(pull|compare)\/(.*?[ \t\r\n]))/\[\3\](\1)/g' $changelog_path - sed -ri 's/\[([0-9]+)\]\((https?:\/\/.*?\/pull\/.*?[ \t\r\n])\)/\[#\1\]\(\2\)/g' $changelog_path - sed -ri 's/@([^ \t\n]+)/[@\1](https:\/\/github\.com\/\1)/g' $changelog_path + sed -ri 's/(https?:\/\/.*?\/(pull|compare)\/([^ \t\r\n]+))/\[\3\](\1)/g' $changelog_path + sed -ri 's/\[([0-9]+)\]\((https?:\/\/.*?\/pull\/[^ \t\r\n]+)\)/\[#\1\]\(\2\)/g' $changelog_path + sed -ri 's/@([^ \t\r\n]+)/[@\1](https:\/\/github\.com\/\1)/g' $changelog_path env: GH_TOKEN: ${{ github.token }} From ca724c6e5c4c55dafa25c632cb4e3fd9d9d5c787 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Thu, 1 Aug 2024 17:05:16 +0300 Subject: [PATCH 31/33] Make 'actions/checkout' pull from 'main' - 'createchangelog' & 'github-pages' Workflow --- .github/workflows/createchangelog.yaml | 23 +---------------------- .github/workflows/github-pages.yaml | 4 ++-- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 976113fe3a..9e95d8cce3 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -16,28 +16,7 @@ jobs: with: fetch-tags: 'true' submodules: 'recursive' - ref: ${{ github.ref }} - - - name: Get correct branch to use for committing changes - id: get_correct_branch - run: | - # NOTE/TODO: - # Because there's a chance where this'll get triggered by a Release Creation, Edit, Deletion.. - # the value of 'github.ref' will be 'refs/tags/TAG-NAME', and this tag can not be handled easily by - # the 'actions/checkout' action.. we need to handle this case by always changing to main branch. - branch_name="" - declare -rA number_of_refname_instances=$(git branch -a | grep -F '${{ github.ref_name }}' | grep -i -v -e 'HEAD\s*detached' | wc --lines) - if [[ $number_of_refname_instances = 0 ]] ; then - branch_name="main" - else - branch_name="${{ github.ref_name }}" - fi - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git switch $branch_name - git pull - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ref: main # Always pull from & push to 'main' branch, as without doing so, it'll cause some problems. - name: Get all releases and update changelog.md file run: | diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml index b20297ebca..fd56eb43b5 100644 --- a/.github/workflows/github-pages.yaml +++ b/.github/workflows/github-pages.yaml @@ -18,14 +18,14 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout Repo + - name: Checkout Repository uses: actions/checkout@v4 # Make sure to get latest commits, like the one committed by the previous job in jobs list. # reference: https://github.com/orgs/community/discussions/110853 with: fetch-tags: 'true' submodules: 'recursive' - ref: ${{ github.ref }} + ref: main # Always pull from & push to 'main' branch, as without doing so, it'll cause some problems. - name: Setup Python uses: actions/setup-python@v4 From 1ab8d7193924b7897360e05895332f85012dd153 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Thu, 1 Aug 2024 17:13:05 +0300 Subject: [PATCH 32/33] Re-Add 'git config' in 'createchangelog' Workflow --- .github/workflows/createchangelog.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 9e95d8cce3..3a44a4735d 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -115,6 +115,8 @@ jobs: - name: Commit and Push Changes run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add docs/changelog.md git commit -m "Update changelog.md with all releases" git push From 125b437bb44d905e62ca18636f3c766e15722571 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Thu, 1 Aug 2024 18:53:34 +0300 Subject: [PATCH 33/33] Update 'createchangelog' Workflow --- .github/workflows/createchangelog.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml index 3a44a4735d..f371186e4e 100644 --- a/.github/workflows/createchangelog.yaml +++ b/.github/workflows/createchangelog.yaml @@ -23,7 +23,7 @@ jobs: # Initialize some values changelog_path="docs/changelog.md" gh release list --exclude-drafts --json tagName,name,isLatest,isPrerelease --limit 1000000 > releases.txt - declare -rA number_of_releases=$(cat releases.txt | grep -Po '"tagName"' | wc --lines) + declare -r number_of_releases=$(cat releases.txt | grep -Po '"tagName"' | wc --lines) # Clear the contents of changelog file echo "" > $changelog_path @@ -31,7 +31,7 @@ jobs: # Write some Initial Content to changelog file echo "# Changelog" >> $changelog_path echo "" >> $changelog_path - echo "WinUtil changelog is based on GitHub Releases, and autogenerated using GitHub Actions." >> $changelog_path + echo "WinUtil change log received from GitHub Releases, it's autogenerated using GitHub Actions." >> $changelog_path echo "" >> $changelog_path echo "!!! warning \"Important\"" >> $changelog_path echo "" >> $changelog_path @@ -97,7 +97,7 @@ jobs: name=${name_arr[$i]} isprerelease=${isprerelease_arr[$i]} islatest=${islatest_arr[$i]} - body=$(gh release view "$tag" --json body --jq .body) + body=$(gh release view "$tag" --json body --jq .body) || { echo "Failed to fetch release body for $tag"; exit 1; } # The generation of changelog file contents echo "# $name" >> $changelog_path