Skip to content

Fix a variable reference in release.ps1 that broke parsing #8

Fix a variable reference in release.ps1 that broke parsing

Fix a variable reference in release.ps1 that broke parsing #8

Workflow file for this run

name: Release
# Builds and drafts a release. Runs when a version tag is pushed (the tag is the bare version, "2.1.0",
# matching <Version> in SpaceSharp.csproj), or by hand from the Actions tab as a dry run that builds everything
# but creates no release.
#
# The build is installer/release.ps1 in three stages: Build (tests and the four app publishes), Pack (installers,
# MSIs and update packages) and Upload (the draft release). They are separate steps so something can go between
# them later, such as code signing of the app exes after Build and of the installers after Pack.
on:
push:
tags: ['[0-9]+.[0-9]+.[0-9]+']
workflow_dispatch:
inputs:
dry_run:
description: Build only; create no release
type: boolean
default: true
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
name: Build and draft
runs-on: windows-latest
env:
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Install vpk
run: dotnet tool install -g vpk
- name: Check that the tag matches the project version
if: github.event_name == 'push'
shell: pwsh
run: |
$csproj = Get-Content .\SpaceSharp\SpaceSharp.csproj -Raw
if ($csproj -notmatch '<Version>([^<]+)</Version>') { throw "No <Version> in SpaceSharp.csproj" }
$version = $Matches[1]
$tag = "${{ github.ref_name }}"
if ($version -ne $tag) { throw "Tag $tag does not match <Version>$version</Version>. Bump the version, commit, and tag that commit." }
if (-not (Select-String -Path .\CHANGELOG.md -Pattern "^## $([regex]::Escape($version))\s*$" -Quiet)) {
throw "CHANGELOG.md has no '## $version' heading. Take '(unreleased)' off it before tagging."
}
if (-not (Select-String -Path .\README.md -Pattern "badge/version-$([regex]::Escape($version))-" -Quiet)) {
throw "The version badge in README.md does not say $version. Update it (img.shields.io/badge/version-$version-F5B82E) before tagging."
}
"Releasing SpaceSharp $version"
# ---------------------------------------------------------------- stage 1: the app
- name: Build
shell: pwsh
run: .\installer\release.ps1 -Stage Build
# ---------------------------------------------------------------- stage 2: the installers
- name: Pack
shell: pwsh
run: .\installer\release.ps1 -Stage Pack
- name: Keep the release assets with the run
uses: actions/upload-artifact@v4
with:
name: release-assets
path: Releases
if-no-files-found: error
# ---------------------------------------------------------------- stage 3: the draft release
- name: Draft the GitHub release
if: env.DRY_RUN != 'true'
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: .\installer\release.ps1 -Stage Upload