Skip to content

Commit

Permalink
build: 自动化打包
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloWRC committed Aug 1, 2024
1 parent bfe1ec0 commit d28dc2e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 29 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/gen-index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Generate Plugin Index

on:
push:

jobs:

build:
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: List files
run: ls

- name: Install Index Generator
run: |
Invoke-WebRequest -Uri https://github.com/ClassIsland/ClassIsland.PluginIndexGenerator/releases/download/latest/ClassIsland.PluginIndexGenerator.zip -OutFile ClassIsland.PluginIndexGenerator.zip
Expand-Archive -Path ClassIsland.PluginIndexGenerator.zip -DestinationPath .
- name: Generate Plugin Index
run: |
mkdir out/source/
./ClassIsland.PluginIndexGenerator.exe index out/source/index.json -b base.json
7z a "./out/index.zip" ./out/source/* -r -mx=9
rm -r -Force out/source/
- name: Generate MD5
run: |
pwsh -ep Bypass -c .\tools\generate-md5.ps1 ./out
- name: Upload to release
uses: ncipollo/release-action@v1
with:
tag: latest
artifacts: ./out/*.zip,./out/*.md5sum
bodyFile: ./out/checksums.md
token: ${{ secrets.GITHUB_TOKEN }}
29 changes: 0 additions & 29 deletions tools/generate-index.ps1

This file was deleted.

36 changes: 36 additions & 0 deletions tools/generate-md5.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
param($path)

echo $path
rm $path/*.md5sum
$files = Get-ChildItem $path
$hashes = [ordered]@{}
$summary = "
> [!important]
> 下载时请注意核对文件MD5是否正确。
| 文件名 | MD5 |
| --- | --- |
"

foreach ($i in $files) {
$name = $i.Name
$hash = Get-FileHash $i -Algorithm MD5
$hashString = $hash.Hash
$hashes.Add($name, $hashString)
Write-Output $hash.Hash > "${i}.md5sum"
$summary += "| $name | ``${hashString}`` |`n"
}

echo $hashes

$json = ConvertTo-Json $hashes -Compress

$summary += "`n<!-- CLASSISLAND_PKG_MD5 ${json} -->"
echo $summary > "$path/checksums.md"
Write-Host "MD5 Summary:" -ForegroundColor Gray
Write-Host $summary -ForegroundColor Gray
Write-Host "----------" -ForegroundColor Gray

#if (-not $GITHUB_ACTION -eq $null) {
# 'MD5_SUMMARY=' + $summary.Replace("`n", "<<") | Out-File -FilePath $env:GITHUB_ENV -Append
#}

0 comments on commit d28dc2e

Please sign in to comment.