-
Notifications
You must be signed in to change notification settings - Fork 2
99 lines (88 loc) · 3.86 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (88 loc) · 3.86 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
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Download OpenVGDB
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Authenticate the API call so we get the 5000/hr limit instead of
# the 60/hr unauthenticated cap shared across the Actions runner pool.
$headers = @{ Authorization = "Bearer $env:GH_TOKEN" }
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/OpenVGDB/OpenVGDB/releases/latest" -Headers $headers
$asset = $release.assets | Where-Object { $_.name -like "openvgdb*" } | Select-Object -First 1
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile openvgdb.zip
Expand-Archive -Path openvgdb.zip -DestinationPath Emutastic/Assets/ -Force
Remove-Item openvgdb.zip
shell: pwsh
- name: Generate Secrets.cs
run: |
@"
namespace Emutastic
{
internal static class Secrets
{
public const string GitHubOAuthClientId = "${{ secrets.OAUTH_CLIENT_ID }}";
public const string ScreenScraperDevId = "${{ secrets.SCREENSCRAPER_DEV_ID }}";
public const string ScreenScraperDevPass = "${{ secrets.SCREENSCRAPER_DEV_PASS }}";
}
}
"@ | Set-Content -Path Emutastic/Secrets.cs -Encoding UTF8
shell: pwsh
- name: Create Cores folder
run: New-Item -ItemType Directory -Force -Path Emutastic/Cores | Out-Null
shell: pwsh
- name: Publish
# Strip the leading 'v' from the tag so /p:Version receives "1.3.10" not "v1.3.10"
# — System.Version doesn't accept the v-prefix. Sets AssemblyVersion / FileVersion
# so the About tab in-app reads the actual release version.
run: |
$tag = "${{ github.ref_name }}"
$ver = $tag.TrimStart('v','V')
dotnet publish Emutastic/Emutastic.csproj /p:PublishProfile=Release-win-x64 /p:Version=$ver
shell: pwsh
- name: Publish Updater
run: |
dotnet publish Emutastic.Updater/Emutastic.Updater.csproj -c Release -r win-x64
shell: pwsh
- name: Zip release
run: |
$version = "${{ github.ref_name }}"
$zipName = "Emutastic-$version-win-x64.zip"
$publishDir = "Emutastic/bin/Publish/win-x64"
# Single-file publish bundles README.txt into the .exe — copy it back
# out alongside the .exe so players can actually read it.
Copy-Item "Emutastic/README.txt" $publishDir -Force
# Include the updater exe alongside the main app
$updaterExe = Get-ChildItem -Path "Emutastic.Updater/bin/Release/net8.0/win-x64" -Filter "Emutastic.Updater.exe" -Recurse | Select-Object -First 1
if ($updaterExe) { Copy-Item $updaterExe.FullName $publishDir -Force }
Compress-Archive -Path "$publishDir/*" -DestinationPath $zipName
echo "ZIP_NAME=$zipName" >> $env:GITHUB_ENV
shell: pwsh
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$tag = "${{ github.ref_name }}"
gh release view $tag *> $null
if ($LASTEXITCODE -eq 0) {
# The release already exists (version re-tagged to rebuild it) — replace the
# binary in place and leave the existing notes, title, and publish date alone.
gh release upload $tag "$env:ZIP_NAME" --clobber
} else {
gh release create $tag "$env:ZIP_NAME" --title "Emutastic $tag" --draft --generate-notes
}
shell: pwsh