Merge pull request #56 from taroj1205/changeset-release/main #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
paths: | |
- "CHANGELOG.md" | |
branches: | |
- main | |
jobs: | |
release: | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [windows-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install dependencies (Windows only) | |
if: matrix.platform == 'windows-latest' | |
run: | | |
npm install -g pnpm | |
pnpm install | |
- name: Build the app | |
run: pnpm tauri build | |
- name: Get Latest Release PR Content | |
id: get-pr-content | |
shell: pwsh | |
run: | | |
try { | |
# Get PR content and explicitly convert the output to string before parsing | |
$prs = (gh pr list --search "author:app/github-actions is:merged" --json number,title,body --limit 1) | Out-String | |
$pr = $prs | ConvertFrom-Json | |
if ($pr) { | |
$prBody = $pr[0].body | |
$lines = $prBody -split '\r?\n' | |
$contentStartIndex = 0 | |
foreach ($index in 0..($lines.Count-1)) { | |
if ($lines[$index] -match '### ') { | |
$contentStartIndex = $index | |
break | |
} | |
} | |
$releaseNotes = ($lines | Select-Object -Skip $contentStartIndex) -join "`n" | |
$releaseNotes = $releaseNotes -replace '####\s', '### ' -replace '###\s', '## ' | |
$releaseNotes = $releaseNotes.Trim() | |
echo "content<<EOF" >> $env:GITHUB_OUTPUT | |
echo $releaseNotes >> $env:GITHUB_OUTPUT | |
echo "EOF" >> $env:GITHUB_OUTPUT | |
} else { | |
echo "No recent changeset PR found" | |
exit 1 | |
} | |
} catch { | |
echo "Error processing PR content: $_" | |
exit 1 | |
} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get Version | |
id: get_version | |
shell: pwsh | |
run: | | |
$version = (Get-Content src-tauri/Cargo.toml | Select-String '^version\s*=\s*"([^"]+)"').Matches.Groups[1].Value | |
echo "version=$version" >> $env:GITHUB_OUTPUT | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
src-tauri/target/release/bundle/msi/*.msi | |
src-tauri/target/release/bundle/nsis/*.exe | |
src-tauri/target/release/Clippr.exe | |
name: Clippr v${{ steps.get_version.outputs.version }} | |
body: ${{ steps.get-pr-content.outputs.content }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |