diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..98ecb71 --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,32 @@ +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 + shell: powershell + working-directory: ${{github.workspace}}\win7 + run: msbuild /m /p:Configuration=Release Win7Notify.sln + + - name: Build toast-win10 + shell: powershell + working-directory: ${{github.workspace}}\win10 + run: cargo build --verbose --release + + - name: Gather artifacts + shell: bash + run: | + 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/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 5675b1a..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,28 +0,0 @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e136fc2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,19 @@ +name: CI + +on: [ push, pull_request ] + +jobs: + build-and-summarize: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Build & Summarize + uses: ./.github/actions/build/ + + - 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..ace1777 --- /dev/null +++ b/.github/workflows/scripts/summarize.py @@ -0,0 +1,40 @@ +#!/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 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) + with open(full + '.md5', 'w', encoding='utf-8') as mf: + mf.write(f"{checksum}") + s.write(f"| {name} | {file_size} | {checksum} |\n") + +if __name__ == '__main__': + main()