diff --git a/.github/scripts/inject-token.ps1 b/.github/scripts/inject-token.ps1 index ac3df9f9b..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" 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 + + + diff --git a/GenHub/GenHub.Windows/Program.cs b/GenHub/GenHub.Windows/Program.cs index 636c13be3..55e86e1f0 100644 --- a/GenHub/GenHub.Windows/Program.cs +++ b/GenHub/GenHub.Windows/Program.cs @@ -36,35 +36,10 @@ public static void Main(string[] args) // Load environment variables (locally) try { - // TraversePath() uses CWD by default. Use BaseDirectory to be sure we start from where the exe is. - var binDir = AppContext.BaseDirectory; - var path = binDir; - var found = false; - - // Search up to 6 levels up - for (int i = 0; i < 6; i++) - { - if (System.IO.File.Exists(System.IO.Path.Combine(path, ".env"))) - { - Env.Load(System.IO.Path.Combine(path, ".env")); - found = true; - break; - } - - var parent = System.IO.Directory.GetParent(path); - if (parent == null) break; - path = parent.FullName; - } - - if (!found) - { - // Fallback to DotNetEnv default traversal just in case - Env.TraversePath().Load(); - } + Env.TraversePath().Load(); } catch (Exception ex) { - Console.WriteLine($"Failed to load environment variables: {ex}"); System.Diagnostics.Debug.WriteLine($"Failed to load environment variables: {ex}"); }