Skip to content

Commit e62276d

Browse files
committed
fix CI shell error
1 parent c7fb303 commit e62276d

1 file changed

Lines changed: 67 additions & 28 deletions

File tree

.github/workflows/build-natives.yml

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ on:
1515

1616
jobs:
1717
build-natives:
18-
runs-on: ${{ matrix.runs-on }}
19-
env:
20-
CI: true
21-
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite
22-
VCPKG_DOWNLOADS: ${{ github.workspace }}/.vcpkg-downloads
23-
VcpkgOSTarget: ${{ matrix.vcpkg-os-target }}
24-
VcpkgPlatformTarget: ${{ matrix.vcpkg-platform-target }}
25-
Configuration: Release
26-
RuntimeIdentifier: ${{ matrix.rid }}
27-
DotnetVerbose: minimal
28-
GenerateBinLog: ${{ github.event.inputs.GenerateBinLog || inputs.GenerateBinLog || false }}
29-
3018
strategy:
3119
fail-fast: false
3220
matrix:
@@ -35,26 +23,45 @@ jobs:
3523
runs-on: windows-latest
3624
vcpkg-os-target: windows
3725
vcpkg-platform-target: x64
26+
run-prefix: ''
3827
- rid: win-arm64
3928
runs-on: windows-11-arm
4029
vcpkg-os-target: windows
4130
vcpkg-platform-target: arm64
31+
run-prefix: ''
4232
- rid: osx-x64
4333
runs-on: macos-15-intel
4434
vcpkg-os-target: osx
4535
vcpkg-platform-target: x64
36+
run-prefix: nix develop .#natives -c bash -eo pipefail -c
4637
- rid: osx-arm64
4738
runs-on: macos-15
4839
vcpkg-os-target: osx
4940
vcpkg-platform-target: arm64
41+
run-prefix: nix develop .#natives -c bash -eo pipefail -c
5042
- rid: linux-x64
5143
runs-on: ubuntu-latest
5244
vcpkg-os-target: linux
5345
vcpkg-platform-target: x64
46+
run-prefix: nix develop .#natives -c bash -eo pipefail -c
5447
- rid: linux-arm64
5548
runs-on: ubuntu-24.04-arm
5649
vcpkg-os-target: linux
5750
vcpkg-platform-target: arm64
51+
run-prefix: nix develop .#natives -c bash -eo pipefail -c
52+
53+
runs-on: ${{ matrix.runs-on }}
54+
env:
55+
CI: true
56+
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite
57+
VCPKG_DOWNLOADS: ${{ github.workspace }}/.vcpkg-downloads
58+
VcpkgOSTarget: ${{ matrix.vcpkg-os-target }}
59+
VcpkgPlatformTarget: ${{ matrix.vcpkg-platform-target }}
60+
RUN_PREFIX: ${{ matrix.run-prefix }}
61+
Configuration: Release
62+
RuntimeIdentifier: ${{ matrix.rid }}
63+
DotnetVerbose: minimal
64+
GenerateBinLog: ${{ github.event.inputs.GenerateBinLog || inputs.GenerateBinLog || false }}
5865

5966
steps:
6067
- name: Checkout
@@ -86,35 +93,67 @@ jobs:
8693
if: runner.os != 'Windows'
8794
uses: cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31.10.6
8895

96+
- name: Setup dev environment
97+
if: runner.os != 'Windows'
98+
shell: pwsh
99+
run: 'true'
100+
89101
- name: Restore
90102
shell: pwsh
91103
run: |
104+
$command = @'
92105
dotnet restore Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj -v ${{ env.DotnetVerbose }} ${{ env.GenerateBinLog == 'true' && '-bl:restore.binlog' || '' }}
106+
'@
107+
108+
if ($env:RUN_PREFIX) {
109+
Invoke-Expression "$env:RUN_PREFIX `"$command`""
110+
}
111+
else {
112+
Invoke-Expression $command
113+
}
93114
94115
- name: Build natives projects for ${{ matrix.rid }}
95-
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'nix develop .#natives -c bash -eo pipefail {0}' }}
96-
run: > # Building tests will build dependencies including the native libraries
97-
dotnet build Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore -v ${{ env.DotnetVerbose }}
98-
${{ env.GenerateBinLog == 'true' && '-bl:build.binlog' || '' }}
99-
-p:AppendNativeAotAppProps="RuntimeIdentifier=${{ env.RuntimeIdentifier }}"
100-
-p:GeneratePackageOnBuild=false -p:CI=false
116+
shell: pwsh
117+
run: | # Building tests will build dependencies including the native libraries
118+
$command = @'
119+
dotnet build Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore -v ${{ env.DotnetVerbose }} ${{ env.GenerateBinLog == 'true' && '-bl:build.binlog' || '' }} -p:AppendNativeAotAppProps="RuntimeIdentifier=${{ env.RuntimeIdentifier }}" -p:GeneratePackageOnBuild=false -p:CI=false
120+
'@
121+
122+
if ($env:RUN_PREFIX) {
123+
Invoke-Expression "$env:RUN_PREFIX `"$command`""
124+
}
125+
else {
126+
Invoke-Expression $command
127+
}
101128
102129
- name: Test natives outputs for ${{ matrix.rid }}
103130
shell: pwsh
104-
run: >
105-
dotnet test Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore --no-build -v ${{ env.DotnetVerbose }}
106-
${{ env.GenerateBinLog == 'true' && '-bl:test.binlog' || '' }}
107-
--logger "console;verbosity=detailed"
108-
--logger GitHubActions
131+
run: |
132+
$command = @'
133+
dotnet test Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore --no-build -v ${{ env.DotnetVerbose }} ${{ env.GenerateBinLog == 'true' && '-bl:test.binlog' || '' }} --logger "console;verbosity=detailed" --logger GitHubActions
134+
'@
135+
136+
if ($env:RUN_PREFIX) {
137+
Invoke-Expression "$env:RUN_PREFIX `"$command`""
138+
}
139+
else {
140+
Invoke-Expression $command
141+
}
109142
110143
- name: Pack NuGet Package for ${{ matrix.rid }}
111144
if: ${{ always() }}
112145
shell: pwsh
113-
run: >
114-
dotnet pack NetCord.Natives/NetCord.Natives.csproj --no-restore --no-build -v ${{ env.DotnetVerbose }}
115-
${{ env.GenerateBinLog == 'true' && '-bl:pack.binlog' || '' }}
116-
-o NetCord.Natives/bin/${{ matrix.rid }}
117-
-p:CI=false
146+
run: |
147+
$command = @'
148+
dotnet pack NetCord.Natives/NetCord.Natives.csproj --no-restore --no-build -v ${{ env.DotnetVerbose }} ${{ env.GenerateBinLog == 'true' && '-bl:pack.binlog' || '' }} -o NetCord.Natives/bin/${{ matrix.rid }} -p:CI=false
149+
'@
150+
151+
if ($env:RUN_PREFIX) {
152+
Invoke-Expression "$env:RUN_PREFIX `"$command`""
153+
}
154+
else {
155+
Invoke-Expression $command
156+
}
118157
119158
- name: Upload Binary Logs
120159
if: ${{ env.GenerateBinLog == 'true' && always() }}

0 commit comments

Comments
 (0)