Skip to content

Fix formatting in build-and-release.yml #33

Fix formatting in build-and-release.yml

Fix formatting in build-and-release.yml #33

name: ⚡ Build & Release RandomGen PowerToys Plugin
on:
push:
tags:
- 'v*'
env:
PLUGIN_DIR: RandomGen/Community.PowerToys.Run.Plugin.RandomGen
ARTIFACT_PREFIX: RandomGen
permissions:
contents: write
issues: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
platform: [x64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('RandomGen/**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Get version
id: get_version
shell: bash
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "IS_TAG=true" >> $GITHUB_OUTPUT
else
echo "VERSION=$(date +'%Y.%m.%d')-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT
echo "IS_TAG=false" >> $GITHUB_OUTPUT
fi
- name: 🚀 Build & stage plugin
shell: pwsh
run: |
# 1. Inject version
$pluginJson = "${{ env.PLUGIN_DIR }}/plugin.json"
$content = Get-Content $pluginJson -Raw | ConvertFrom-Json
$content.Version = "${{ steps.get_version.outputs.VERSION }}"
$content | ConvertTo-Json -Depth 10 | Set-Content $pluginJson -Encoding UTF8
# 2. Build
dotnet build "${{ env.PLUGIN_DIR }}/Community.PowerToys.Run.Plugin.RandomGen.csproj" `
-c Release `
-p:Platform="${{ matrix.platform }}"
# 3. Locate binaries
$outDir = "${{ env.PLUGIN_DIR }}/bin/${{ matrix.platform }}/Release"
$netDir = Get-ChildItem $outDir -Directory -Filter "net*-windows*" |
Select-Object -First 1 -ExpandProperty FullName
if (-not $netDir) { throw "Build output not found" }
# 4. Stage folder
$stage = "artifacts/${{ env.ARTIFACT_PREFIX }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}/${{ env.ARTIFACT_PREFIX }}"
New-Item $stage -ItemType Directory -Force | Out-Null
# 5. Copy files
Copy-Item "$netDir/*" $stage -Recurse -Exclude @(
"PowerToys*.dll","PowerToys*.pdb","Wox*.dll","Wox*.pdb"
)
Copy-Item $pluginJson $stage
Copy-Item "${{ env.PLUGIN_DIR }}/Images" $stage -Recurse -ErrorAction SilentlyContinue
- name: 📦 Zip & upload artifact
shell: pwsh
run: |
$zip = "artifacts/${{ env.ARTIFACT_PREFIX }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}.zip"
$src = "artifacts/${{ env.ARTIFACT_PREFIX }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform }}/${{ env.ARTIFACT_PREFIX }}"
Compress-Archive -Path $src -DestinationPath $zip
- uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ matrix.platform }}
path: artifacts/*.zip
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: downloaded-artifacts
- name: Prepare artifacts for release
run: |
mkdir -p release-artifacts
VERSION="${{ steps.get_version.outputs.VERSION }}"
cp downloaded-artifacts/build-artifacts-x64/${{ env.ARTIFACT_PREFIX }}-${VERSION}-x64.zip release-artifacts/
cp downloaded-artifacts/build-artifacts-arm64/${{ env.ARTIFACT_PREFIX }}-${VERSION}-arm64.zip release-artifacts/
- name: Prepare release notes
id: release_notes
run: |
VERSION="${{ steps.get_version.outputs.VERSION }}"
cat > release_notes.md << EOL
# 🎲 RandomGen v${VERSION} – Unleashed!
<p align="center">
<img src="https://github.com/ruslanlap/PowerToysRun-RandomGen/raw/master/assets/randomgen.logo.png" width="128" alt="RandomGen Logo"/>
</p>
## ✨ What’s New
- 🔐 **Enhanced Password Generator** (customizable options)
- 🚀 Turbocharged performance
- 🛡️ Bug fixes & PTRUN compliance
## 🧙‍♂️ Install
1. Download ZIP for your arch (x64 / ARM64)
2. Extract to `%LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Plugins\RandomGen`
3. Restart PowerToys → press `Alt+Space` → type `rd <command>`
## ⚡ Commands
| Incantation | Magic |
|-------------|-------|
| `rd password [len]` | Forge a password |
| `rd pin [len]` | Numeric PIN |
| `rd guid` | Fresh GUID |
| `rd number min-max` | Random number |
| `rd name` | Random name |
| `rd email` | Random email |
| `rd date` | Random date |
| `rd color` | Hex color |
## 💫 Contribute
Found a bug or have an idea? [Open an issue](https://github.com/ruslanlap/PowerToysRun-RandomGen/issues).
Crafted with ✨ cosmic energy ✨ by [ruslanlap](https://github.com/ruslanlap)
EOL
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
cat release_notes.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Generate SHA256 checksums
run: |
cd release-artifacts
VERSION="${{ steps.get_version.outputs.VERSION }}"
for f in *.zip; do
sha256sum "$f" | tee "$f.sha256"
done
{
echo "SHA256 Checksums for RandomGen Plugin v${VERSION}"
echo "Generated on: $(date -u)"
echo
cat *.sha256
} > checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: RandomGen v${{ steps.get_version.outputs.VERSION }}
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
draft: false
prerelease: false
files: |
release-artifacts/${{ env.ARTIFACT_PREFIX }}-${{ steps.get_version.outputs.VERSION }}-x64.zip
release-artifacts/${{ env.ARTIFACT_PREFIX }}-${{ steps.get_version.outputs.VERSION }}-arm64.zip
release-artifacts/*.sha256
release-artifacts/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}