Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/scripts/inject-token.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down Expand Up @@ -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 }}"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
8 changes: 8 additions & 0 deletions GenHub/GenHub.Windows/GenHub.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
<EmbeddedResource Include="Resources\update_genhub.ps1" />
</ItemGroup>

<!-- Copy .env file to output directory for local debugging if it exists -->
<ItemGroup Condition="Exists('..\..\.env')">
<None Include="..\..\.env">
<Link>.env</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GenHub\GenHub.csproj" />
<ProjectReference Include="..\GenHub.Core\GenHub.Core.csproj" />
Expand Down
27 changes: 1 addition & 26 deletions GenHub/GenHub.Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}

Expand Down
Loading