-
-
Notifications
You must be signed in to change notification settings - Fork 190
126 lines (105 loc) · 4.77 KB
/
Copy pathrelease.yml
File metadata and controls
126 lines (105 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Create Release (Windows)
on:
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
env:
CODE_SIGN_USER: ${{ secrets.CODE_SIGN_USER }}
CODE_SIGN_PASS: ${{ secrets.CODE_SIGN_PASS }}
CODE_SIGN_TOTP_SECRET: ${{ secrets.CODE_SIGN_TOTP_SECRET }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_DIR: ${{ github.workspace }}\publish-wj
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Download CodeSignTool
shell: pwsh
run: |
$url = "https://github.com/SSLcom/CodeSignTool/releases/download/v1.3.2/CodeSignTool-v1.3.2-windows.zip"
$zip = "$env:RUNNER_TEMP\CodeSignTool.zip"
$extractRoot = "${{ github.workspace }}\CodeSignTool"
Invoke-WebRequest -Uri $url -OutFile $zip
Expand-Archive -Path $zip -DestinationPath $extractRoot -Force
# Locate the directory containing CodeSignTool.bat (zip may extract with or without nested folder)
$batFile = Get-ChildItem $extractRoot -Recurse -Filter "CodeSignTool.bat" | Select-Object -First 1
if (-not $batFile) { throw "CodeSignTool.bat not found after extraction" }
$codeSignDir = $batFile.Directory.FullName
Write-Host "CodeSignTool installed at: $codeSignDir"
"CODE_SIGN_DIR=$codeSignDir" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Build, sign, package, and create GitHub draft release
id: build
shell: pwsh
run: ./release.ps1
# --- Nexus Mods uploads (official action) ---
- name: Upload launcher to Nexus Mods
uses: Nexus-Mods/upload-action@v1.0.0-beta.8
with:
api_key: ${{ secrets.NEXUS_API_KEY }}
file_id: "1328371"
filename: ${{ github.workspace }}\publish-wj\Wabbajack.zip
version: ${{ steps.build.outputs.version }}
display_name: Wabbajack.zip
description: |
Version - ${{ steps.build.outputs.version }} - download this file
Changelog: https://github.com/wabbajack-tools/wabbajack/releases/tag/${{ steps.build.outputs.version }}
category: main
- name: Upload full release to Nexus Mods
uses: Nexus-Mods/upload-action@v1.0.0-beta.8
with:
api_key: ${{ secrets.NEXUS_API_KEY }}
file_id: "1328362"
filename: ${{ github.workspace }}\publish-wj\${{ steps.build.outputs.version }}.zip
version: ${{ steps.build.outputs.version }}
display_name: ${{ steps.build.outputs.version }}.zip
description: "Release files, ignore this unless you're sure you need it"
category: optional
# --- Publish & announce ---
- name: Publish GitHub release
shell: pwsh
run: |
gh release edit "${{ steps.build.outputs.version }}" --draft=false
Write-Host "Release ${{ steps.build.outputs.version }} is now live!"
- name: Post to Discord
shell: pwsh
env:
DISCORD_RELEASE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
run: |
if (-not $env:DISCORD_RELEASE_WEBHOOK) {
Write-Host "DISCORD_RELEASE_WEBHOOK not set, skipping"
exit 0
}
$version = "${{ steps.build.outputs.version }}"
# Extract changelog section for this version
$content = Get-Content CHANGELOG.md -Raw
$releaseNotes = ""
if ($content -match "(?ms)(#### Version - $([regex]::Escape($version)) - .+?)(?=\r?\n#### Version - |\z)") {
$releaseNotes = $Matches[1].Trim()
}
$header = @"
$version is released
Please download via the launcher or via the link on the website: https://www.wabbajack.org/
Or on the Nexus: https://www.nexusmods.com/site/mods/403
"@
$header = ($header -split "`n" | ForEach-Object { $_.Trim() }) -join "`n"
function Send-DiscordMessage {
param([string]$Content)
$payload = @{ content = $Content; flags = 4 } | ConvertTo-Json -Depth 5 -Compress
Invoke-RestMethod -Uri $env:DISCORD_RELEASE_WEBHOOK -Method POST `
-ContentType "application/json" -Body $payload | Out-Null
}
$fullMessage = "$header`n`n$releaseNotes"
if ($fullMessage.Length -le 2000) {
Send-DiscordMessage -Content $fullMessage
} else {
Write-Host "Message exceeds 2000 chars, splitting"
Send-DiscordMessage -Content $header
Send-DiscordMessage -Content $releaseNotes
}
Write-Host "Posted to Discord"