Use Github Releases?

#230 · closed · 10 comments

View on GitHub ↗

fdcastel

Hi @nightroman! Would you be interested in publishing each `Invoke-Build` release under the GitHub Releases section of the project? - At the moment, only tags are available: https://github.com/nightroman/Invoke-Build/tags - However, it could be like this: https://github.com/PowerShell/PowerShell/releases I noticed you've started treading some waters in `.github/workflows`, though it looks like those are currently just for tests. If you're interested, I'd be happy to help out with some PRs to get release automation set up. We could also look into improving the [release notes](https://github.com/nightroman/Invoke-Build/blob/main/Release-Notes.md) process, which seems a bit manual at the moment. As always, thanks for all your excellent work! I've been a long-time fan and always use Invoke-Build in all my projects.

Comments

nightroman

Hi @fdcastel Maybe, not sure. We have releases as such. Why do we need GitHub Releases in addition?

nightroman

> We could also look into improving the [release notes](https://github.com/nightroman/Invoke-Build/blob/main/Release-Notes.md) process, which seems a bit manual at the moment. In this project the typical release flow is "one change -- one commit -- release". I think manual release notes work rather well in this case, there is not much to automate here.

nightroman

Invoke-Build CI automation is actually based on manually changed release notes (adding a new version section) https://github.com/nightroman/Invoke-Build/blob/980df2a23ce87393607bb3907791eb69cdc2c548/.build.ps1#L49-L52 And then other automated tasks use this version for packaging, tagging, pushing, etc.

fdcastel

> Why do we need GitHub Releases This might just be a nitpick, but I often find myself visiting a GitHub project and immediately checking the “Releases” section on the right-hand side of the page. Clicking it takes me straight to the releases page, where I can easily browse the latest versions and changelogs. Another advantage is that this information is exposed through the GitHub API, allowing external tools to automatically detect and respond to new releases.

fdcastel

Maybe not the best use case scenario for Invoke-Build, but an example of using GitHub api to query a project's release can be seen [here](https://github.com/FirebirdSQL/firebird-docker/blob/master/firebird-docker.build.ps1#L105). _Proudly made with Invoke-Build!_ 😄

nightroman

Let me think about this. How would you automate this process? (without generated release notes perhaps)

fdcastel

Using GitHub Actions is actually quite simple! I've been toying with them recently, which is why I'm recommending them to you. You can check out a straightforward example [here](https://github.com/fdcastel/qemu-img-windows-x64/blob/master/.github/workflows/release.yml). This project simply repackages some binaries and publishes them as a new release on the [Releases page](https://github.com/fdcastel/qemu-img-windows-x64/releases) of the project.

nightroman

@fdcastel We are getting there :) The first release https://github.com/nightroman/Invoke-Build/releases/tag/v5.14.13 created by build script like ```powershell function last_release_notes { $text = Get-Content -Raw Release-Notes.md $re = [regex]'##\s+v(\d+\.\d+\.\d+)' $m1 = $re.Match($text) $m2 = $m1.NextMatch() assert ($m1.Success -and $m2.Success) $st = $m1.Index + $m1.Length $text.Substring($st, $m2.Index - $st) } # Synopsis: Create release from tag. task makeRelease version, { $tag = "v$Version" $url = "https://api.github.com/repos/nightroman/Invoke-Build/releases" $headers = [ordered]@{ Accept = "application/vnd.github+json" Authorization = "Bearer $env:GITHUB_TOKEN" "X-GitHub-Api-Version" = "2022-11-28" } $body = [ordered]@{ tag_name = $tag name = $tag body = last_release_notes } | ConvertTo-Json $null = Invoke-RestMethod -Method Post -Uri $url -Headers $headers -Body $body -ContentType application/json } ```

nightroman

Done, releases are now created automatically by [Release.build.ps1](https://github.com/nightroman/Invoke-Build/blob/main/Tasks/Steps/Release.build.ps1) which calls this (for now with interactive confirmation, to be removed later) https://github.com/nightroman/Invoke-Build/blob/5143adb12e8f795e5d5a3c97104167eaa2a5f133/.build.ps1#L160-L188

fdcastel

Fantastic work! 🚀 😄 👍🏻