Skip to content

Commit 8e376f8

Browse files
committed
ci: Fix release action and don't double-zip.
1 parent 23a2b50 commit 8e376f8

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- uses: actions/cache@v4
3636
with:
3737
path: ${{ github.workspace }}\.nuget\packages
38-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files
38+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
3939
restore-keys: |
4040
${{ runner.os }}-nuget-
4141
@@ -50,7 +50,7 @@ jobs:
5050
5151
- name: Restore NuGet packages
5252
run: nuget restore DmdExtensions.sln
53-
53+
5454
- name: Restore DLLExport dependency
5555
run: .\DllExport -action Restore -sln-file DmdExtensions.sln
5656

@@ -67,7 +67,6 @@ jobs:
6767
$minor=$match.groups[2].value -as [int]
6868
$patch=$match.groups[3].value -as [int]
6969
$revision=$match.groups[4].value -as [int]
70-
7170
return $fileContent -replace "^[^/]*\[assembly:\s*$name\(\""[^""]*\""\)", "[assembly: $name(""$major.$minor.$patch.$env:GITHUB_RUN_NUMBER"")"
7271
}
7372
}
@@ -84,25 +83,16 @@ jobs:
8483
$patch=$match.groups[3].value -as [int]
8584
$tag=$match.groups[5].value
8685
87-
# Get branch name from GitHub context
88-
$branch = if ($env:GITHUB_HEAD_REF) {
89-
$env:GITHUB_HEAD_REF # For pull requests
90-
} else {
91-
$env:GITHUB_REF_NAME # For direct pushes
92-
}
86+
$branch = if ($env:GITHUB_HEAD_REF) { $env:GITHUB_HEAD_REF } else { $env:GITHUB_REF_NAME }
9387
9488
if ($branch -eq "master" -or $branch -eq "main") {
95-
if ($tag) {
96-
$version = "$major.$minor.$patch-$tag-r$env:GITHUB_RUN_NUMBER"
97-
} else {
98-
$version = "$major.$minor.$patch-r$env:GITHUB_RUN_NUMBER"
99-
}
89+
if ($tag) { $version = "$major.$minor.$patch-$tag-r$env:GITHUB_RUN_NUMBER" }
90+
else { $version = "$major.$minor.$patch-r$env:GITHUB_RUN_NUMBER" }
10091
} else {
10192
$version = "$major.$minor.$patch-$($branch.ToUpper())-r$env:GITHUB_RUN_NUMBER"
102-
}
93+
}
10394
104-
Write-Host "Changing version from $major.$minor.$patch-$tag to $version"
105-
# Set output for other steps to use
95+
Write-Host "Changing version to $version"
10696
"version=$version" >> $env:GITHUB_OUTPUT
10797
10898
return $fileContent -replace "^[^/]*\[assembly:\s*$name\(\""[^""]*\""\)", "[assembly: $name(""$version"")"
@@ -123,12 +113,10 @@ jobs:
123113
124114
$assemblyFile = "VersionAssemblyInfo.cs"
125115
$fileContent = Get-Content $assemblyFile
126-
127116
$fileContent = replaceNumericVersion 'AssemblyVersion' $fileContent
128117
$fileContent = replaceNumericVersion 'AssemblyFileVersion' $fileContent
129118
$fileContent = replaceFullVersion 'AssemblyInformationalVersion' $fileContent
130119
131-
# Check if this is not a tag build
132120
if (-not $env:GITHUB_REF.StartsWith("refs/tags/")) {
133121
$fileContent = replaceAny 'AssemblyConfiguration' $env:GITHUB_SHA.Substring(0, 7) $fileContent
134122
}
@@ -138,47 +126,53 @@ jobs:
138126
139127
- name: Build
140128
run: msbuild -t:rebuild /p:Platform=${{ matrix.platform }} /p:Configuration=${{ matrix.configuration }} DmdExtensions.sln
141-
129+
142130
- name: Build installer
143131
run: msbuild /p:Platform=${{ matrix.platform }} /p:Configuration=${{ matrix.configuration }} /p:SolutionDir="$env:GITHUB_WORKSPACE\" .\Installer\Installer.wixproj
144132

145133
- name: Generate zip bundle
146134
shell: pwsh
147135
run: |
148136
$version = if ($env:GITHUB_REF.StartsWith("refs/tags/")) { $env:GITHUB_REF_NAME } else { $env:GITHUB_SHA.Substring(0, 7) }
149-
$zipArchive = "$env:GITHUB_WORKSPACE\Installer\Builds\dmdext-$version-${{ matrix.platform }}.zip"
150-
New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\Installer\Builds"
151-
137+
$outDir = "$env:GITHUB_WORKSPACE\Installer\Builds"
138+
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
139+
$zipArchive = Join-Path $outDir "dmdext-$version-${{ matrix.platform }}.zip"
140+
152141
Compress-Archive -Path "$env:GITHUB_WORKSPACE\Console\bin\${{ matrix.platform }}\${{ matrix.configuration }}\dmdext.exe" -DestinationPath $zipArchive -Force
153142
Compress-Archive -Path "$env:GITHUB_WORKSPACE\Console\bin\${{ matrix.platform }}\${{ matrix.configuration }}\dmdext.log.config" -Update -DestinationPath $zipArchive
154143
Compress-Archive -Path "$env:GITHUB_WORKSPACE\Console\ProPinballSlave.bat" -Update -DestinationPath $zipArchive
155144
156145
$dllSuffix = if ('${{ matrix.platform }}' -eq 'x64') { '64' } else { '' }
157146
Compress-Archive -Path "$env:GITHUB_WORKSPACE\PinMameDevice\bin\${{ matrix.platform }}\${{ matrix.configuration }}\DmdDevice$dllSuffix.dll" -Update -DestinationPath $zipArchive
158147
Compress-Archive -Path "$env:GITHUB_WORKSPACE\PinMameDevice\bin\${{ matrix.platform }}\${{ matrix.configuration }}\DmdDevice.log.config" -Update -DestinationPath $zipArchive
159-
# Copy DmdDevice.ini in a temporary Destination folder
160-
Copy-Item -Path "$env:GITHUB_WORKSPACE\PinMameDevice\DmdDevice.ini" -Destination (New-Item -Type Directory -Force "$env:GITHUB_WORKSPACE\ini-template")
161-
Compress-Archive -Path "$env:GITHUB_WORKSPACE\ini-template" -Update -DestinationPath $zipArchive
162-
Remove-Item "$env:GITHUB_WORKSPACE\ini-template" -Recurse
163-
148+
149+
# Include default ini template as a folder inside the zip
150+
Copy-Item -Path "$env:GITHUB_WORKSPACE\PinMameDevice\DmdDevice.ini" -Destination (New-Item -Type Directory -Force "$env:GITHUB_WORKSPACE\ini-template") | Out-Null
151+
Compress-Archive -Path "$env:GITHUB_WORKSPACE\ini-template\*" -Update -DestinationPath $zipArchive
152+
Remove-Item "$env:GITHUB_WORKSPACE\ini-template" -Recurse -Force
153+
154+
# Include 'data' folder contents as 'dmdext' directory inside the zip
164155
Rename-Item "$env:GITHUB_WORKSPACE\PinMameDevice\data" "$env:GITHUB_WORKSPACE\PinMameDevice\dmdext"
165-
Compress-Archive -Path "$env:GITHUB_WORKSPACE\PinMameDevice\dmdext" -Update -DestinationPath $zipArchive
166-
156+
Compress-Archive -Path "$env:GITHUB_WORKSPACE\PinMameDevice\dmdext\*" -Update -DestinationPath $zipArchive
167157
Rename-Item "$env:GITHUB_WORKSPACE\PinMameDevice\dmdext" "$env:GITHUB_WORKSPACE\PinMameDevice\data"
168158
159+
# Upload the already-zipped bundle
169160
- name: Upload ZIP artifacts
170161
uses: actions/upload-artifact@v4
171162
with:
172163
name: dmdext-${{ matrix.platform }}-zip
173164
path: ${{ github.workspace }}\Installer\Builds\*.zip
165+
compression-level: 0
174166
retention-days: 90
175167
if-no-files-found: error
176168

169+
# Upload the MSI as-is (not placed inside the zip)
177170
- name: Upload installer artifacts
178171
uses: actions/upload-artifact@v4
179172
with:
180173
name: dmdext-${{ matrix.platform }}-msi
181174
path: ${{ github.workspace }}\Installer\Builds\*.msi
175+
compression-level: 0
182176
retention-days: 90
183177
if-no-files-found: error
184178

@@ -187,16 +181,22 @@ jobs:
187181
runs-on: ubuntu-latest
188182
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
189183
steps:
184+
# Download both matrix artifacts by pattern and merge into the workspace
190185
- name: Download ZIP artifacts
191186
uses: actions/download-artifact@v4
192187
with:
193-
name: dmdext-${{ matrix.platform }}-zip
188+
pattern: dmdext-*-zip
189+
merge-multiple: true
190+
194191
- name: Download MSI artifacts
195192
uses: actions/download-artifact@v4
196193
with:
197-
name: dmdext-${{ matrix.platform }}-msi
198-
- name: ls
199-
run: ls -alrt
194+
pattern: dmdext-*-msi
195+
merge-multiple: true
196+
197+
- name: List files
198+
run: ls -alR
199+
200200
- name: Create Release
201201
uses: ncipollo/release-action@v1
202202
with:

0 commit comments

Comments
 (0)