From 313c5f59de439447edf2c5ffb0e928f417ad01e9 Mon Sep 17 00:00:00 2001 From: ChrisTitusTech Date: Sun, 28 Jul 2024 15:32:00 +0000 Subject: [PATCH 1/4] =?UTF-8?q?Deploying=20to=20main=20from=20@=20ChrisTit?= =?UTF-8?q?usTech/winutil@7de93ae20857cc30477f9da7b7dc48c15b8deb58=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4f4fc20e3..7db6f373a7 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ If you have Issues, refer to [Known Issues](https://christitustech.github.io/win These are the sponsors that help keep this project alive with monthly contributions. -Gregory NavasarkianYusuke SaitoTriHyderaMark AmosJason A. DiegmuellerwyattJan WilleOwenStefanthaddlDave Jones +Gregory NavasarkianYusuke SaitoTriHyderaMark AmosJason A. DiegmuellerwyattJan WilleOwenStefanthaddlPaulDave Jones ## 🏅 Thanks to all Contributors Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻. From dbae03dd3419544cd99927a20b8bef0a14e581e6 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 05:53:58 +0300 Subject: [PATCH 2/4] Workflow update/fix createchangelog not running (#21) * Make workflows re-usable * Rename File Extensions for some workflow files * Change job ordering * Try something else to force specific job ordering * Another Try something else to force specific job ordering * Add comments & rename some jobs * 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. * Add reference to 'Checkout Repo' step * Fix Admonition in Changelog Workflow * Remove un-used 'release.yaml' workflow * Add 'release' event to 'github-pages' workflow * Fix Admonition in Changelog Workflow * Make 'actions/checkout' fetch latest of anything, git submodules, tags, and commits * Fix yaml syntax error * Handle special case in 'createchangelog.yaml' workflow * Update workflows * Fix issue with 'createchangelog' workflow always switching to Git Detached Head Mode * Reorder 'env' field in 'createchangelog' workflow * Fix 'close-discussion' workflow not working --- ...e-discussion.yml => close-discussion.yaml} | 2 +- .github/workflows/createchangelog.yaml | 136 ++++++++++++++++++ .github/workflows/createchangelog.yml | 113 --------------- .github/workflows/github-pages.yaml | 41 ++++++ .github/workflows/github-pages.yml | 22 --- .github/workflows/pre-release.yaml | 13 +- .github/workflows/release.yaml | 44 ------ .../workflows/{sponsors.yml => sponsors.yaml} | 0 8 files changed, 190 insertions(+), 181 deletions(-) rename .github/workflows/{close-discussion.yml => close-discussion.yaml} (92%) create mode 100644 .github/workflows/createchangelog.yaml delete mode 100644 .github/workflows/createchangelog.yml create mode 100644 .github/workflows/github-pages.yaml delete mode 100644 .github/workflows/github-pages.yml delete mode 100644 .github/workflows/release.yaml rename .github/workflows/{sponsors.yml => sponsors.yaml} (100%) diff --git a/.github/workflows/close-discussion.yml b/.github/workflows/close-discussion.yaml similarity index 92% rename from .github/workflows/close-discussion.yml rename to .github/workflows/close-discussion.yaml index 252b7823b2..306134d797 100644 --- a/.github/workflows/close-discussion.yml +++ 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 diff --git a/.github/workflows/createchangelog.yaml b/.github/workflows/createchangelog.yaml new file mode 100644 index 0000000000..f95a4ff7b7 --- /dev/null +++ b/.github/workflows/createchangelog.yaml @@ -0,0 +1,136 @@ +name: Update changelog.md on Release + +on: + workflow_dispatch: # Manual trigger added + workflow_call: # Make this Working a re-usable one (can be called form another workflow) + +jobs: + update-changelog-file: + runs-on: ubuntu-latest + + 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: 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 + 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 + echo "" >> $changelog_path + echo "$body" >> $changelog_path + echo "" >> $changelog_path + done + env: + GH_TOKEN: ${{ github.token }} + + - 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 }} diff --git a/.github/workflows/createchangelog.yml b/.github/workflows/createchangelog.yml deleted file mode 100644 index 6251f9a5a6..0000000000 --- a/.github/workflows/createchangelog.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Update changelog.md on Release - -on: - release: - types: [published, created, edited, deleted] - workflow_dispatch: # Add this line to enable manual triggering - -jobs: - update-file: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - 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 change log received from GitHub Releases, it's 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 "" >> $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 diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml new file mode 100644 index 0000000000..b20297ebca --- /dev/null +++ b/.github/workflows/github-pages.yaml @@ -0,0 +1,41 @@ +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) + +permissions: + contents: write + +jobs: + update-changelog: + uses: ./.github/workflows/createchangelog.yaml + + bulid-deploy-gh-pages: + # Make sure 'update-changelog' run first, then run this job afterward + needs: update-changelog + runs-on: ubuntu-latest + + 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. + # reference: https://github.com/orgs/community/discussions/110853 + with: + fetch-tags: 'true' + submodules: 'recursive' + ref: ${{ github.ref }} + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.x + + - 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/github-pages.yml b/.github/workflows/github-pages.yml deleted file mode 100644 index 486d1ed96f..0000000000 --- a/.github/workflows/github-pages.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: GitHub Pages Deploy -on: - release: - types: [published, prereleased] - workflow_dispatch: -permissions: - contents: write -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - 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 diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 34e04d3210..5edc1a6c0e 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -8,11 +8,17 @@ on: workflow_dispatch: # Manual trigger added jobs: - build-runspace: + release: runs-on: windows-latest 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: Extract Version from winutil.ps1 id: extract_version @@ -46,3 +52,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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index df5f3d5d74..0000000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: Release WinUtil - -on: - workflow_dispatch: # Manual trigger added - -jobs: - build-runspace: - 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 }} 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 8c1721b8a40aaa15dcb3712bdedcb6b8d162f76a Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 06:04:23 +0300 Subject: [PATCH 3/4] Workflow update/fix createchangelog not running (#22) * Make workflows re-usable * Rename File Extensions for some workflow files * Change job ordering * Try something else to force specific job ordering * Another Try something else to force specific job ordering * Add comments & rename some jobs * 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. * Add reference to 'Checkout Repo' step * Fix Admonition in Changelog Workflow * Remove un-used 'release.yaml' workflow * Add 'release' event to 'github-pages' workflow * Fix Admonition in Changelog Workflow * Make 'actions/checkout' fetch latest of anything, git submodules, tags, and commits * Fix yaml syntax error * Handle special case in 'createchangelog.yaml' workflow * Update workflows * Fix issue with 'createchangelog' workflow always switching to Git Detached Head Mode * Reorder 'env' field in 'createchangelog' workflow * Fix 'close-discussion' workflow not working * 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..f3be9e4d1a 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_id}" + 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 79aecdcb8f6e09cf10d88fd5bc9c6be7178c858b Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 29 Jul 2024 06:32:53 +0300 Subject: [PATCH 4/4] Workflow update/fix createchangelog not running (#23) * Make workflows re-usable * Rename File Extensions for some workflow files * Change job ordering * Try something else to force specific job ordering * Another Try something else to force specific job ordering * Add comments & rename some jobs * 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. * Add reference to 'Checkout Repo' step * Fix Admonition in Changelog Workflow * Remove un-used 'release.yaml' workflow * Add 'release' event to 'github-pages' workflow * Fix Admonition in Changelog Workflow * Make 'actions/checkout' fetch latest of anything, git submodules, tags, and commits * Fix yaml syntax error * Handle special case in 'createchangelog.yaml' workflow * Update workflows * Fix issue with 'createchangelog' workflow always switching to Git Detached Head Mode * Reorder 'env' field in 'createchangelog' workflow * Fix 'close-discussion' workflow not working * Add debug info to 'close-discussion' workflow * Maybe this'll fix 'close-discussion.yml' Workflow --- .github/workflows/close-discussion.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/close-discussion.yaml b/.github/workflows/close-discussion.yaml index f3be9e4d1a..cbb0e34c71 100644 --- a/.github/workflows/close-discussion.yaml +++ b/.github/workflows/close-discussion.yaml @@ -22,12 +22,8 @@ jobs: 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 - + 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_id}" echo "IDs Array: ${discussion_ids_arr[@]}" echo "IDs List:"