diff --git a/.github/scripts/inject-token.ps1 b/.github/scripts/inject-token.ps1
index f23310325..d132dc711 100644
--- a/.github/scripts/inject-token.ps1
+++ b/.github/scripts/inject-token.ps1
@@ -3,8 +3,8 @@ param(
)
if ([string]::IsNullOrEmpty($Token)) {
- Write-Host "No UPLOADTHING_TOKEN provided. Skipping injection. Build will use empty/default token."
- exit 0
+ Write-Error "No UPLOADTHING_TOKEN provided. Fails for Release builds."
+ exit 1
}
$constantsPath = "GenHub/GenHub.Core/Constants/ApiConstants.cs"
@@ -26,9 +26,16 @@ $dataStr = ($obfuscated | ForEach-Object { "0x{0:x2}" -f $_ }) -join ", "
$keyStr = ($key | ForEach-Object { "0x{0:x2}" -f $_ }) -join ", "
$content = Get-Content $constantsPath -Raw
-# Replace the placeholders we put in the static property
-$content = $content -replace 'byte\[\] data = \[\]; // \[PLACEHOLDER_DATA\]', "byte[] data = [$dataStr];"
-$content = $content -replace 'byte\[\] key = \[\]; // \[PLACEHOLDER_KEY\]', "byte[] key = [$keyStr];"
+
+# Use regex replace to be robust against whitespace
+# Pattern: byte[] data = []; // [PLACEHOLDER_DATA]
+$content = [System.Text.RegularExpressions.Regex]::Replace($content, 'byte\[\]\s+data\s*=\s*\[\];\s*//\s*\[PLACEHOLDER_DATA\]', "byte[] data = [$dataStr];")
+$content = [System.Text.RegularExpressions.Regex]::Replace($content, 'byte\[\]\s+key\s*=\s*\[\];\s*//\s*\[PLACEHOLDER_KEY\]', "byte[] key = [$keyStr];")
+
+if ($content -notmatch "0x") {
+ Write-Error "Token injection failed! Placeholders were not found or replaced."
+ exit 1
+}
Set-Content $constantsPath $content
Write-Host "Successfully injected and obfuscated UPLOADTHING_TOKEN into ApiConstants.cs"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 94173ca60..c8b87d792 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -123,6 +123,11 @@ jobs:
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "CHANNEL=$channel" >> $env:GITHUB_OUTPUT
+ - name: Inject Secrets
+ shell: pwsh
+ run: |
+ ./.github/scripts/inject-token.ps1 -Token "${{ secrets.UPLOADTHING_TOKEN }}"
+
- name: Build Projects
shell: pwsh
run: |
@@ -142,10 +147,6 @@ jobs:
Write-Host "Building Windows project"
dotnet build "${{ env.WINDOWS_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} @buildProps
- - name: Inject Secrets
- shell: pwsh
- run: |
- ./.github/scripts/inject-token.ps1 -Token "${{ secrets.UPLOADTHING_TOKEN }}"
- name: Publish Windows App
shell: pwsh
@@ -284,6 +285,11 @@ jobs:
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
+ - name: Inject Secrets
+ shell: pwsh
+ run: |
+ ./.github/scripts/inject-token.ps1 -Token "${{ secrets.UPLOADTHING_TOKEN }}"
+
- name: Build Projects
run: |
BUILD_PROPS="-p:Version=${{ steps.buildinfo.outputs.VERSION }} -p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }} -p:PullRequestNumber=${{ steps.buildinfo.outputs.PR_NUMBER }} -p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5b338d5e2..9cee9e205 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -221,6 +221,6 @@ jobs:
${{ steps.info.outputs.CHANGELOG }}
### 🔧 Assets
- - **Installer:** `GenHub-win-Setup.exe`
- - **Portable:** `GenHub-${{ steps.info.outputs.VERSION }}-win-portable.zip`
+ - **Installer:** [GenHub-win-Setup.exe](https://github.com/${{ github.repository }}/releases/download/v${{ steps.info.outputs.VERSION }}/GenHub-win-Setup.exe)
+ - **Portable:** [GenHub-${{ steps.info.outputs.VERSION }}-win-portable.zip](https://github.com/${{ github.repository }}/releases/download/v${{ steps.info.outputs.VERSION }}/GenHub-${{ steps.info.outputs.VERSION }}-win-portable.zip)
files: final-assets/*
diff --git a/GenHub/GenHub.Windows/GenHub.Windows.csproj b/GenHub/GenHub.Windows/GenHub.Windows.csproj
index be5610dce..4e5308ac9 100644
--- a/GenHub/GenHub.Windows/GenHub.Windows.csproj
+++ b/GenHub/GenHub.Windows/GenHub.Windows.csproj
@@ -29,6 +29,14 @@
+
+
+
+ .env
+ PreserveNewest
+
+
+