From 2c067d10e0330938db68d224f7df2b923b0e456d Mon Sep 17 00:00:00 2001
From: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
Date: Tue, 5 Aug 2025 10:18:03 +0800
Subject: [PATCH 1/6] ci: md5 checksums
---
.../build.yml => actions/build/action.yml} | 51 +++++++++----------
.github/actions/summarize/action.yml | 12 +++++
.github/workflows/ci.yml | 22 ++++++++
.github/workflows/scripts/summarize.py | 37 ++++++++++++++
4 files changed, 94 insertions(+), 28 deletions(-)
rename .github/{workflows/build.yml => actions/build/action.yml} (56%)
create mode 100644 .github/actions/summarize/action.yml
create mode 100644 .github/workflows/ci.yml
create mode 100644 .github/workflows/scripts/summarize.py
diff --git a/.github/workflows/build.yml b/.github/actions/build/action.yml
similarity index 56%
rename from .github/workflows/build.yml
rename to .github/actions/build/action.yml
index 5675b1a..befe36f 100644
--- a/.github/workflows/build.yml
+++ b/.github/actions/build/action.yml
@@ -1,28 +1,23 @@
-name: Build
-
-on:
- push:
- branches: [ "master" ]
-
-jobs:
- build:
- runs-on: windows-latest
-
- steps:
- - uses: actions/checkout@v4
-
- - name: Add MSBuild to PATH
- uses: microsoft/setup-msbuild@v1.0.2
- - name: Build toast-win10
- working-directory: ${{github.workspace}}\win10
- run: cargo build --verbose --release
- - name: Build toast-win7
- working-directory: ${{github.workspace}}\win7
- run: msbuild /m /p:Configuration=Release Win7Notify.sln
- - name: Upload
- uses: actions/upload-artifact@v4
- with:
- name: ChatToolsAddon
- path: |
- win7/x64/Release/toast-win7.exe
- win10/target/release/toast-win10.exe
\ No newline at end of file
+name: Build
+
+runs:
+ using: composite
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Add MSBuild to PATH
+ uses: microsoft/setup-msbuild@v1.0.2
+
+ - name: Build toast-win7
+ working-directory: ${{github.workspace}}\win7
+ run: msbuild /m /p:Configuration=Release Win7Notify.sln
+
+ - name: Build toast-win10
+ working-directory: ${{github.workspace}}\win10
+ run: cargo build --verbose --release
+
+ - name: Gather artifacts
+ run: |
+ mkdir -p gathered_artifacts
+ mv win7/x64/Release/toast-win7.exe gathered_artifacts/
+ mv win10/target/release/toast-win10.exe gathered_artifacts/
diff --git a/.github/actions/summarize/action.yml b/.github/actions/summarize/action.yml
new file mode 100644
index 0000000..e96d6a1
--- /dev/null
+++ b/.github/actions/summarize/action.yml
@@ -0,0 +1,12 @@
+name: Generate MD5 files and summarize
+
+runs:
+ using: composite
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Summarize
+ run: |
+ chmod +x .github/workflows/scripts/summarize.py
+ python3 .github/workflows/scripts/summarize.py gathered_artifacts
+ shell: bash
\ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..93835b4
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,22 @@
+name: CI
+
+on: [ push, pull_request ]
+
+jobs:
+ build-and-summary:
+ runs-on: windows-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Build
+ uses: ./.github/actions/build/
+
+ - name: Summarize
+ uses: ./.github/actions/summarize/
+
+ - name: Upload
+ uses: actions/upload-artifact@v4
+ with:
+ name: ChatToolsAddon
+ path: gathered_artifacts/
\ No newline at end of file
diff --git a/.github/workflows/scripts/summarize.py b/.github/workflows/scripts/summarize.py
new file mode 100644
index 0000000..ba551ca
--- /dev/null
+++ b/.github/workflows/scripts/summarize.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+import sys
+import os
+import hashlib
+
+def compute_md5(filepath, chunk_size=8192):
+ md5 = hashlib.md5()
+ with open(filepath, 'rb') as f:
+ for chunk in iter(lambda: f.read(chunk_size), b''):
+ md5.update(chunk)
+ return md5.hexdigest()
+
+def main():
+ if len(sys.argv) != 2:
+ print(f"Usage: {sys.argv[0]}
")
+ sys.exit(1)
+
+ target_dir = sys.argv[1]
+ summary_path = os.environ.get('GITHUB_STEP_SUMMARY')
+ if not summary_path:
+ print("No GITHUB_STEP_SUMMARY!")
+ sys.exit(1)
+
+ entries = sorted(os.listdir(target_dir))
+ with open(summary_path, 'a', encoding='utf-8') as summary:
+ summary.write("## MD5 Checksums`\n\n")
+ for name in entries:
+ full = os.path.join(target_dir, name)
+ if os.path.isfile(full):
+ checksum = compute_md5(full)
+ md5_file = full + '.md5'
+ with open(md5_file, 'w', encoding='utf-8') as mf:
+ mf.write(f"{checksum}")
+ summary.write(f"- `{name}`: `{checksum}`\n")
+
+if __name__ == '__main__':
+ main()
From 717641254f71684b7694a31513f2455437637e93 Mon Sep 17 00:00:00 2001
From: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
Date: Tue, 5 Aug 2025 10:22:11 +0800
Subject: [PATCH 2/6] ci: fix shell template
---
.github/actions/build/action.yml | 2 ++
.github/actions/summarize/action.yml | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml
index befe36f..8856548 100644
--- a/.github/actions/build/action.yml
+++ b/.github/actions/build/action.yml
@@ -9,10 +9,12 @@ runs:
uses: microsoft/setup-msbuild@v1.0.2
- name: Build toast-win7
+ shell: bash
working-directory: ${{github.workspace}}\win7
run: msbuild /m /p:Configuration=Release Win7Notify.sln
- name: Build toast-win10
+ shell: bash
working-directory: ${{github.workspace}}\win10
run: cargo build --verbose --release
diff --git a/.github/actions/summarize/action.yml b/.github/actions/summarize/action.yml
index e96d6a1..97857e9 100644
--- a/.github/actions/summarize/action.yml
+++ b/.github/actions/summarize/action.yml
@@ -6,7 +6,7 @@ runs:
- uses: actions/checkout@v4
- name: Summarize
+ shell: bash
run: |
chmod +x .github/workflows/scripts/summarize.py
python3 .github/workflows/scripts/summarize.py gathered_artifacts
- shell: bash
\ No newline at end of file
From 71f9de2bc95568d65a7282f06eaf94d4f26d173f Mon Sep 17 00:00:00 2001
From: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
Date: Tue, 5 Aug 2025 10:23:00 +0800
Subject: [PATCH 3/6] ci: another shell
---
.github/actions/build/action.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml
index 8856548..54dc3b5 100644
--- a/.github/actions/build/action.yml
+++ b/.github/actions/build/action.yml
@@ -19,6 +19,7 @@ runs:
run: cargo build --verbose --release
- name: Gather artifacts
+ shell: bash
run: |
mkdir -p gathered_artifacts
mv win7/x64/Release/toast-win7.exe gathered_artifacts/
From 72c74d0085c06a373496c5c089e4b621bae49bb5 Mon Sep 17 00:00:00 2001
From: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
Date: Tue, 5 Aug 2025 10:27:19 +0800
Subject: [PATCH 4/6] ci: don't use bash
---
.github/actions/build/action.yml | 4 ++--
.github/workflows/ci.yml | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml
index 54dc3b5..9a0301e 100644
--- a/.github/actions/build/action.yml
+++ b/.github/actions/build/action.yml
@@ -9,12 +9,12 @@ runs:
uses: microsoft/setup-msbuild@v1.0.2
- name: Build toast-win7
- shell: bash
+ shell: powershell
working-directory: ${{github.workspace}}\win7
run: msbuild /m /p:Configuration=Release Win7Notify.sln
- name: Build toast-win10
- shell: bash
+ shell: powershell
working-directory: ${{github.workspace}}\win10
run: cargo build --verbose --release
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 93835b4..72068d9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3,7 +3,7 @@ name: CI
on: [ push, pull_request ]
jobs:
- build-and-summary:
+ build-and-summarize:
runs-on: windows-latest
steps:
From 66427838648bc208fe2a425c32b0de31b231d335 Mon Sep 17 00:00:00 2001
From: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
Date: Tue, 5 Aug 2025 10:34:17 +0800
Subject: [PATCH 5/6] ci: fix
---
.github/actions/build/action.yml | 6 ++++++
.github/actions/summarize/action.yml | 12 ------------
.github/workflows/ci.yml | 5 +----
3 files changed, 7 insertions(+), 16 deletions(-)
delete mode 100644 .github/actions/summarize/action.yml
diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml
index 9a0301e..98ecb71 100644
--- a/.github/actions/build/action.yml
+++ b/.github/actions/build/action.yml
@@ -24,3 +24,9 @@ runs:
mkdir -p gathered_artifacts
mv win7/x64/Release/toast-win7.exe gathered_artifacts/
mv win10/target/release/toast-win10.exe gathered_artifacts/
+
+ - name: Summarize
+ shell: bash
+ run: |
+ chmod +x .github/workflows/scripts/summarize.py
+ python3 .github/workflows/scripts/summarize.py gathered_artifacts
\ No newline at end of file
diff --git a/.github/actions/summarize/action.yml b/.github/actions/summarize/action.yml
deleted file mode 100644
index 97857e9..0000000
--- a/.github/actions/summarize/action.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-name: Generate MD5 files and summarize
-
-runs:
- using: composite
- steps:
- - uses: actions/checkout@v4
-
- - name: Summarize
- shell: bash
- run: |
- chmod +x .github/workflows/scripts/summarize.py
- python3 .github/workflows/scripts/summarize.py gathered_artifacts
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 72068d9..e136fc2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -9,12 +9,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- - name: Build
+ - name: Build & Summarize
uses: ./.github/actions/build/
- - name: Summarize
- uses: ./.github/actions/summarize/
-
- name: Upload
uses: actions/upload-artifact@v4
with:
From ea03bc9854f0f543b80a03d869f3d3e3e4da211a Mon Sep 17 00:00:00 2001
From: 70CentsApple <63957117+70CentsApple@users.noreply.github.com>
Date: Tue, 5 Aug 2025 10:44:00 +0800
Subject: [PATCH 6/6] ci: better summary
---
.github/workflows/scripts/summarize.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/scripts/summarize.py b/.github/workflows/scripts/summarize.py
index ba551ca..ace1777 100644
--- a/.github/workflows/scripts/summarize.py
+++ b/.github/workflows/scripts/summarize.py
@@ -22,16 +22,19 @@ def main():
sys.exit(1)
entries = sorted(os.listdir(target_dir))
- with open(summary_path, 'a', encoding='utf-8') as summary:
- summary.write("## MD5 Checksums`\n\n")
+ with open(summary_path, 'a', encoding='utf-8') as s:
+ s.write("## MD5 Checksums:\n\n")
+ s.write('| File | Size | MD5 |\n')
+ s.write('| --- | --- | --- |\n')
+
for name in entries:
full = os.path.join(target_dir, name)
if os.path.isfile(full):
+ file_size = f'{os.path.getsize(full)} B'
checksum = compute_md5(full)
- md5_file = full + '.md5'
- with open(md5_file, 'w', encoding='utf-8') as mf:
+ with open(full + '.md5', 'w', encoding='utf-8') as mf:
mf.write(f"{checksum}")
- summary.write(f"- `{name}`: `{checksum}`\n")
+ s.write(f"| {name} | {file_size} | {checksum} |\n")
if __name__ == '__main__':
main()