1- name : Build and Release RandomGen
1+ name : Build and Release RandomGen Plugin
22
33on :
4- workflow_dispatch :
54 push :
6- branches :
7- - main
8- - master
95 tags :
106 - ' v*'
117
8+ # Permissions for GITHUB_TOKEN (principle of least privilege)
129permissions :
1310 contents : write # Needed for creating releases
1411 issues : read
1512 pull-requests : read
1613
14+ # Add restrictions for parallel runs
1715concurrency :
1816 group : ${{ github.workflow }}-${{ github.ref }}
1917 cancel-in-progress : true
@@ -24,16 +22,16 @@ jobs:
2422 strategy :
2523 matrix :
2624 platform : [x64, arm64]
27-
25+
2826 steps :
2927 - name : Checkout code
3028 uses : actions/checkout@v4
31-
29+
3230 - name : Setup .NET
3331 uses : actions/setup-dotnet@v4
3432 with :
3533 dotnet-version : ' 9.0.x'
36-
34+
3735 - name : Get version
3836 id : get_version
3937 shell : bash
4543 echo "VERSION=$(date +'%Y.%m.%d')-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT
4644 echo "IS_TAG=false" >> $GITHUB_OUTPUT
4745 fi
48-
46+
4947 - name : Update plugin.json version
5048 run : |
5149 $version = "${{ steps.get_version.outputs.VERSION }}"
@@ -58,26 +56,88 @@ jobs:
5856 Write-Host "Updated plugin.json version to: $version"
5957 }
6058 shell : pwsh
61-
59+
6260 - name : Build
63- shell : pwsh
64- run : |
65- dotnet build RandomGen/Community.PowerToys.Run.Plugin.RandomGen/Community.PowerToys.Run.Plugin.RandomGen.csproj -c Release -p:Platform="${{ matrix.platform }}"
66-
67- - name : Publish
68- shell : pwsh
69- run : |
70- dotnet publish RandomGen/Community.PowerToys.Run.Plugin.RandomGen/Community.PowerToys.Run.Plugin.RandomGen.csproj -c Release -p:Platform="${{ matrix.platform }}" -o ./Publish/${{ matrix.platform }}
71-
72- - name : Create artifacts directory
61+ run : dotnet build RandomGen/Community.PowerToys.Run.Plugin.RandomGen/Community.PowerToys.Run.Plugin.RandomGen.csproj -c Release -p:Platform="${{ matrix.platform }}"
62+
63+ - name : Create output directory
7364 run : mkdir -p artifacts
74-
65+
7566 - name : Copy build output to artifacts directory
76- shell : pwsh
7767 run : |
7868 $artifactDir = "artifacts/RandomGen-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}"
69+
70+ New-Item -ItemType Directory -Force -Path $artifactDir
7971 New-Item -ItemType Directory -Force -Path "$artifactDir/RandomGen"
80- Copy-Item -Path "./Publish/${{ matrix.platform }}/*" -Destination "$artifactDir/RandomGen" -Recurse -Force
72+
73+ # Copy Images folder (icons) to artifact directory to ensure correct icons in release
74+ $imagesSrc = "RandomGen/Community.PowerToys.Run.Plugin.RandomGen/Images"
75+ $imagesDst = "$artifactDir/RandomGen/Images"
76+ if (Test-Path $imagesSrc) {
77+ Write-Host "Copying Images folder from $imagesSrc to $imagesDst"
78+ Copy-Item -Path $imagesSrc -Destination $imagesDst -Recurse -Force
79+ } else {
80+ Write-Host "Images folder not found at $imagesSrc"
81+ }
82+
83+ # Define the direct path to the build output
84+ $buildOutput = "RandomGen/Community.PowerToys.Run.Plugin.RandomGen/bin/${{ matrix.platform }}/Release"
85+
86+ Write-Host "Using build output directory: $buildOutput"
87+
88+ # Check if the directory exists
89+ if (-not (Test-Path $buildOutput)) {
90+ Write-Host "Build output directory not found at expected path. Searching for it..."
91+ $buildOutput = Get-ChildItem -Path "RandomGen" -Recurse -Directory |
92+ Where-Object { $_.Name -eq "Release" -and $_.FullName -like "*${{ matrix.platform }}*" } |
93+ Select-Object -First 1 -ExpandProperty FullName
94+
95+ if ($buildOutput) {
96+ Write-Host "Found build output directory: $buildOutput"
97+ } else {
98+ Write-Error "Could not find any Release directory for platform ${{ matrix.platform }}"
99+ exit 1
100+ }
101+ }
102+
103+ # Check if build output exists before proceeding
104+ if (-not (Test-Path $buildOutput)) {
105+ Write-Error "Build output directory not found"
106+ exit 1
107+ }
108+
109+ # Check for files directly in the build output directory
110+ $files = Get-ChildItem -Path $buildOutput -File
111+ if ($files.Count -gt 0) {
112+ Write-Host "Found $($files.Count) files in build output directory. Copying directly..."
113+ Get-ChildItem -Path $buildOutput -File | ForEach-Object {
114+ Copy-Item -Path $_.FullName -Destination "$artifactDir/RandomGen" -Force
115+ }
116+ Write-Host "Files copied successfully"
117+ } else {
118+ # Look for a .NET runtime folder
119+ $runtimeFolder = Get-ChildItem -Path $buildOutput -Directory |
120+ Where-Object { $_.Name -like "net*-windows*" } |
121+ Select-Object -First 1 -ExpandProperty FullName
122+
123+ if ($runtimeFolder) {
124+ Write-Host "Found runtime folder: $runtimeFolder"
125+ Copy-Item -Path "$runtimeFolder\*" -Destination "$artifactDir/RandomGen" -Recurse -Force
126+ Write-Host "Files copied successfully from runtime folder"
127+ } else {
128+ # If no runtime folder, check for any subdirectories
129+ $subDirs = Get-ChildItem -Path $buildOutput -Directory
130+ if ($subDirs.Count -gt 0) {
131+ $firstSubDir = $subDirs[0].FullName
132+ Write-Host "No runtime folder found, but found subdirectory: $firstSubDir"
133+ Copy-Item -Path "$firstSubDir\*" -Destination "$artifactDir/RandomGen" -Recurse -Force
134+ Write-Host "Files copied from first subdirectory"
135+ } else {
136+ Write-Error "No files or subdirectories found in build output directory"
137+ exit 1
138+ }
139+ }
140+ }
81141
82142 # Remove unnecessary PowerToys DLLs that are provided by the host
83143 $unnecessaryDlls = @(
@@ -95,34 +155,40 @@ jobs:
95155 Remove-Item $item.FullName -Force
96156 }
97157 }
98-
99- - name : Create ZIP archive
100158 shell : pwsh
159+
160+ - name : Create ZIP archive
101161 run : |
102162 $artifactDir = "artifacts/RandomGen-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}"
103- $zipFile = "RandomGen-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}.zip"
104- Compress-Archive -Path "$artifactDir/RandomGen" -DestinationPath "artifacts/$zipFile"
105-
163+ $zipName = "RandomGen-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}.zip"
164+ # Create ZIP with RandomGen folder inside
165+ Compress-Archive -Path "$artifactDir/RandomGen" -DestinationPath "artifacts/$zipName"
166+ shell : pwsh
167+
106168 - name : Upload build artifacts
107169 uses : actions/upload-artifact@v4
108170 with :
109171 name : build-artifacts-${{ matrix.platform }}
110172 path : artifacts/*.zip
111-
173+
112174 release :
113175 needs : build
114176 runs-on : ubuntu-latest
115177 if : startsWith(github.ref, 'refs/tags/v')
116-
178+
117179 steps :
118180 - name : Checkout code
119181 uses : actions/checkout@v4
120-
182+
183+ - name : Get version from tag
184+ id : get_version
185+ run : echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
186+
121187 - name : Download all artifacts
122188 uses : actions/download-artifact@v4
123189 with :
124190 path : downloaded-artifacts
125-
191+
126192 # Debug step to see what files are available
127193 - name : List downloaded artifacts
128194 run : |
@@ -132,35 +198,21 @@ jobs:
132198 ls -la downloaded-artifacts/build-artifacts-x64 || echo "No x64 artifacts found"
133199 echo "Listing ARM64 artifacts:"
134200 ls -la downloaded-artifacts/build-artifacts-arm64 || echo "No ARM64 artifacts found"
135-
201+
136202 # Copy artifacts to the expected location with the correct names
137203 - name : Prepare artifacts for release
138204 run : |
139205 mkdir -p release-artifacts
140- VERSION="${GITHUB_REF#refs/tags/v }"
206+ VERSION="${{ steps.get_version.outputs.VERSION } }"
141207 cp downloaded-artifacts/build-artifacts-x64/RandomGen-${VERSION}-x64.zip release-artifacts/ || echo "Failed to copy x64 artifact"
142- cp downloaded-artifacts/build-artifacts-arm64/RandomGen-${VERSION}-arm64.zip release-artifacts/RandomGen-${VERSION}-ARM64.zip || echo "Failed to copy ARM64 artifact"
208+ cp downloaded-artifacts/build-artifacts-arm64/RandomGen-${VERSION}-arm64.zip release-artifacts/ || echo "Failed to copy ARM64 artifact"
143209 echo "Listing release artifacts:"
144210 ls -la release-artifacts
145-
146- - name : Generate SHA256 checksums
147- run : |
148- cd release-artifacts
149- VERSION="${GITHUB_REF#refs/tags/v}"
150- sha256sum RandomGen-${VERSION}-x64.zip | tr 'a-f' 'A-F' > RandomGen-${VERSION}-x64.zip.sha256
151- sha256sum RandomGen-${VERSION}-ARM64.zip | tr 'a-f' 'A-F' > RandomGen-${VERSION}-ARM64.zip.sha256
152-
153- # Create combined checksums.txt file
154- echo "SHA256 Checksums for RandomGen Plugin v${VERSION}" > checksums.txt
155- echo "Generated on: $(date -u)" >> checksums.txt
156- echo "" >> checksums.txt
157- cat RandomGen-${VERSION}-x64.zip.sha256 >> checksums.txt
158- cat RandomGen-${VERSION}-ARM64.zip.sha256 >> checksums.txt
159-
211+
160212 - name : Prepare Release Notes
161213 id : release_notes
162214 run : |
163- VERSION="${GITHUB_REF#refs/tags/v }"
215+ VERSION="${{ steps.get_version.outputs.VERSION } }"
164216 cat > release_notes.md << EOL
165217 # 🎲 RandomGen v${VERSION} - Unleashed!
166218
@@ -174,26 +226,27 @@ jobs:
174226 - 🚀 Turbocharged performance for lightning-fast randomness
175227 - 🛡️ Squashed those pesky bugs that were hiding in the shadows
176228 - 🔮 Magical new features to supercharge your productivity
229+ - 🔧 PTRUN Compliance: All PowerToys Run linting issues resolved (PTRUN1301, PTRUN1303, PTRUN1401, PTRUN1402)
177230
178231 ## 🧙♂️ Installation Magic
179232
180233 1. 📦 Download the mystical ZIP file for your realm (x64 or ARM64)
181- 2. 🔓 Extract the arcane contents to `%LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Plugins\RandomGen`
234+ 2. 🔓 Extract the arcane contents to \ `%LOCALAPPDATA%\\ Microsoft\\ PowerToys\\ PowerToys Run\\ Plugins\\ RandomGen\ `
182235 3. 🔄 Summon a PowerToys restart to activate the spell
183- 4. ✨ Invoke the power with `Alt+Space` then conjure `rd` followed by your command
236+ 4. ✨ Invoke the power with \ `Alt+Space\ ` then conjure \ `rd\ ` followed by your command
184237
185238 ## ⚡ Spellbook of Commands
186239
187240 | Incantation | What Magic It Performs |
188241 |------------------------|-----------------------------------|
189- | `rd password [length]` | Forge an unbreakable password |
190- | `rd pin [length]` | Conjure a mystical numeric PIN |
191- | `rd guid` | Summon a unique dimensional GUID |
192- | `rd number min-max` | Roll cosmic dice within your range |
193- | `rd name` | Generate an identity from the void |
194- | `rd email` | Materialize a digital address |
195- | `rd date` | Pluck a random day from the timeline|
196- | `rd color` | Extract a chromatic hex essence |
242+ | \ `rd password [length]\ ` | Forge an unbreakable password |
243+ | \ `rd pin [length]\ ` | Conjure a mystical numeric PIN |
244+ | \ `rd guid\ ` | Summon a unique dimensional GUID |
245+ | \ `rd number min-max\ ` | Roll cosmic dice within your range |
246+ | \ `rd name\ ` | Generate an identity from the void |
247+ | \ `rd email\ ` | Materialize a digital address |
248+ | \ `rd date\ ` | Pluck a random day from the timeline|
249+ | \ `rd color\ ` | Extract a chromatic hex essence |
197250
198251 ## 💫 Join the RandomGen Universe
199252
@@ -204,35 +257,33 @@ jobs:
204257 echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
205258 cat release_notes.md >> $GITHUB_OUTPUT
206259 echo "EOF" >> $GITHUB_OUTPUT
207-
260+
261+ - name : Generate SHA256 checksums
262+ run : |
263+ cd release-artifacts
264+ VERSION="${{ steps.get_version.outputs.VERSION }}"
265+ sha256sum RandomGen-${VERSION}-x64.zip | tr 'a-f' 'A-F' > RandomGen-${VERSION}-x64.zip.sha256
266+ sha256sum RandomGen-${VERSION}-arm64.zip | tr 'a-f' 'A-F' > RandomGen-${VERSION}-arm64.zip.sha256
267+
268+ # Create combined checksums.txt file
269+ echo "SHA256 Checksums for RandomGen Plugin v${VERSION}" > checksums.txt
270+ echo "Generated on: $(date -u)" >> checksums.txt
271+ echo "" >> checksums.txt
272+ cat RandomGen-${VERSION}-x64.zip.sha256 >> checksums.txt
273+ cat RandomGen-${VERSION}-arm64.zip.sha256 >> checksums.txt
274+
208275 - name : Create Release
209- id : create_release
210- uses : softprops/action-gh-release@v2
276+ uses : softprops/action-gh-release@v1
211277 with :
212- name : RandomGen v${GITHUB_REF#refs/tags/v }
278+ name : RandomGen v${{ steps.get_version.outputs.VERSION } }
213279 body : ${{ steps.release_notes.outputs.RELEASE_NOTES }}
214280 draft : false
215281 prerelease : false
216282 files : |
217- release-artifacts/RandomGen-${GITHUB_REF#refs/tags/v }-x64.zip
218- release-artifacts/RandomGen-${GITHUB_REF#refs/tags/v}-ARM64 .zip
219- release-artifacts/RandomGen-${GITHUB_REF#refs/tags/v }-x64.zip.sha256
220- release-artifacts/RandomGen-${GITHUB_REF#refs/tags/v}-ARM64 .zip.sha256
283+ release-artifacts/RandomGen-${{ steps.get_version.outputs.VERSION } }-x64.zip
284+ release-artifacts/RandomGen-${{ steps.get_version.outputs.VERSION }}-arm64 .zip
285+ release-artifacts/RandomGen-${{ steps.get_version.outputs.VERSION } }-x64.zip.sha256
286+ release-artifacts/RandomGen-${{ steps.get_version.outputs.VERSION }}-arm64 .zip.sha256
221287 release-artifacts/checksums.txt
222-
223- - name : Create Latest Release Artifacts
224- if : success()
225- run : |
226- mkdir -p latest_release
227- cp release-artifacts/RandomGen-${GITHUB_REF#refs/tags/v}-x64.zip latest_release/RandomGen-latest-x64.zip
228- cp release-artifacts/RandomGen-${GITHUB_REF#refs/tags/v}-ARM64.zip latest_release/RandomGen-latest-arm64.zip
229-
230- - name : Update Latest Release Artifacts
231- if : success()
232- uses : softprops/action-gh-release@v2
233- with :
234- name : RandomGen v${GITHUB_REF#refs/tags/v}
235- tag_name : latest
236- files : |
237- latest_release/RandomGen-latest-x64.zip
238- latest_release/RandomGen-latest-arm64.zip
288+ env :
289+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments