GitHub: Creating Releases
web csharp apps ai
Been creating some scripts to automate the creation of releases on GitHub. It was not hard to script the process but making so only repository owners can create releases was a bit more tricky.
Preamble
There is a sample GitHub WPF Hello World repository with scripts such you can can action the creation of a new incremented release but with a guard that only those who can commit to the repository can create a new release.
The site: djaus2/HelloWo4rldWPFApp
Discussion
The infrastructure for this site was developed with the help of GitHub Copilot. This quickly facilitated a PowerShell script that triggered a repository workflow orchestrated by a .yml file. The problem was that script could be run by anyone regardless of whether they had push rights to the repository or not. Also it was desired that the app name could be passed from the ps script to the workflow. The idea was that the ps script and workflow files could be copied to another project and reused simply by passing the app name from the ps.
The AI went around in circles, hallucinated on this and I had to come up with a workable way to implement to do this. Indeed it was suggesting puting authentication in the ps script but that would have only have been cosmetic because it already had demonstrated that it could generate the 2 files such that credentials weren’t required!
App name
For reuse, it is assumed that the app project folder is one deep in the solution folder.
As per here:
SolutionFolder ├─ HelloWo4rldWPFApp.sln ├─ etc ... ├─ HelloWo4rldWPFApp │ ├─ HelloWo4rldWPFApp.csproj │ ├─ App.xaml │ ├─ App.xaml.cs │ ├─ MainWindow.xaml │ ├─ MainWindow.xaml.cs │ └─ etc ... ├─ scripts │ └─ release.ps1 └─ .github └─ workflows └─ release.yml
The workflow file is in the .github/workflows folder and the ps script is in the scripts folder.
The app name here is HelloWo4rldWPFApp. So it was envisaged that a copy of scripts and .github folders to a new project might be all that is required after the app name change in the ps, passing it through to the workflow file. This is one place where the AI did hallucinate suggesting solutions which were not solutions.
The solution wrt to the app name was to require its edit the workflow file when copied to a new context.
The Simple Hello World
This is a simple “Hello World” project. The project includes basic code that outputs “Hello, World!” to a form.
Getting Started
To get started with this project, you’ll need to clone the repository and open it in your favorite IDE. Once you have the project set up, you can build and run the application to see the “Hello, World!” output.
Release Workflow Integrity
It was proposed and implemented that the best way was to have two versions of the workflow file. One that supports creating a new release and one that doesn’t. Scripts were developed to switch between the two requiring both requiring a commit to the repository this putting the required guard in place.
When “disabled” the ps fails as per:
PS C:\User\source\repos\HelloWo4rldWPFApp> scripts\release.ps1
C:\Users\david\source\repos\HelloWo4rldWPFApp\scripts\release.ps1 : Release workflow does not appear active (release action / trigger missing or commented). Aborting to avoid incrementing the version.
At line:1 char:1
+ scripts\release.ps1
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,release.ps1
To enable releases, run scripts/enable-release-workflow.ps1 or re-enable the workflow manually.
The scripts in /scripts folder are:
- enable-release-workflow.ps1
- disable-release-workflow.ps1 … enable and disable creating a new release by modifying the workflow file. The difference is shown below by the green commented out lines for disable mode which are enabled temporarily for a new release:
- release.ps1 … This orchestrates the release process and sets the workflow in motion.
The workflows files in /.github/workflows folder are: - release.yml … The disabled version of the workflow file.
- release.yml.bak.disable … The enabled version of the workflow file. This is restored by the enable-release-workflow.ps1 script and backed up by the disable-release-workflow.ps1 script. Note that the app name only appears in the workflows file.
on:
push:
branches:
- master
- main # Run on every commit
# tags:
# - 'v*' # Run on version tags (v1.0.0 etc.)
# workflow_dispatch:
# inputs:
# app_name:
# description: 'Optional application name to use for artifact/release'
# required: false
# # default intentionally removed; job-level env provides the single source-of-truth
#
# permissions:
# contents: write # Required to create releases
The disabled workflow file
Creating a Release
To create a release for the application, follow these steps:
- The version number is auto=incremented in the form 1.0.nn
- Push the changes to the remote repository.
- Run
./scripts/release.ps1 -DryRunto check without creating a new Release- The version does get auto-incremented though.
- Run
scripts/enable-release-workflow.ps1to enable the release workflow. - Run
./scripts/release.ps1 - Run
scripts/disable-release-workflow.ps1to disable the release workflow. Important - There are some scripts for resetting the version.
Use
- Set the app name in release.yml as above if using in new app.
- Run
scripts/enable-release-workflow.ps1Changes release.yml so that when release.ps1 is run a new release IS created. - Run
scripts/disable-release-workflow.ps1Changes release.yml so that when release.ps1 is run no new release is created. - Leave in disable state between releases.
- Both involve a repository commit so user needs to be logged in with push rights which is the protection we wanted all along! :)
An Example of the above in action:
- Enable Release
- Create Release
- Disable Release
PS c:\User\source\repos\HelloWo4rldWPFApp> scripts\enable-release-workflow.ps1
Restored .github\workflows\release.yml from backup and removed backup: .github\workflows\release.yml.bak.disable
[master 930f417] chore(release): enable release workflow (automated) [2026-07-07T15:14:16]
1 file changed, 19 insertions(+), 19 deletions(-)
Pushing commit to origin/master...
...
...
Workflow restored and change pushed to origin/master.
PS c:\User\source\repos\HelloWo4rldWPFApp> scripts\release.ps1
Last version found: v1.0.23
Auto-incremented version: v1.0.24
Creating tag v1.0.24...
...
...
* [new tag] v1.0.24 -> v1.0.24
✅ Release triggered for v1.0.24
PS c:\User\source\repos\HelloWo4rldWPFApp> scripts\disable-release-workflow.ps1
Backup created: .github\workflows\release.yml.bak.disable
...
...
Workflow disabled and change pushed to origin/master.
| Topic | Subtopic | |
| Next: > | IoT Hub | Quick setup ... with help from AI |
| < Prev: | M365Image | Using AI to remove background from an image |
| This Category Links | ||
| Category: | Web Sites Index: | Web Sites |