Allow specifying MSI version via env var and workflow input (#15828)

# Description

This PR enhances the MSI release workflow by allowing the MSI package
version to be specified either through an environment variable or a
workflow input. This improvement provides greater flexibility when
building MSI packages for tags that do **not** match the latest package
version in `Cargo.toml`.

Fix possible **403** error while updating `SHA256SUMS` file in the
nushell/nightly repo

# User-Facing Changes
None

# Tests + Formatting
A example running record:
https://github.com/nushell/nightly/actions/runs/15265879087/job/42931344366#step:5:11
This commit is contained in:
Justin Ma 2025-05-28 21:03:01 +08:00 committed by GitHub
parent cbd7608898
commit ff4907ed3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -11,10 +11,12 @@
def build-msi [] {
let target = $env.TARGET
let version = (open Cargo.toml | get package.version)
# We should read the version from the environment variable first
# As we may build the MSI package for a specific version not the latest one
let version = $env.MSI_VERSION? | default (open Cargo.toml | get package.version)
let arch = if $nu.os-info.arch =~ 'x86_64' { 'x64' } else { 'arm64' }
print $'Building msi package for (ansi g)($target)(ansi reset) with version (ansi g)($env.REF)(ansi reset)'
print $'Building msi package for (ansi g)($target)(ansi reset) with version (ansi g)($version)(ansi reset) from tag (ansi g)($env.REF)(ansi reset)...'
fetch-nu-pkg
# Create extra Windows msi release package if dotnet and wix are available
let installed = [dotnet wix] | all { (which $in | length) > 0 }

View File

@ -10,6 +10,12 @@ on:
tag:
required: true
description: 'Tag to Rebuild MSI'
version:
description: 'Version of Rebuild MSI'
permissions:
contents: write
packages: write
defaults:
run:
@ -61,6 +67,7 @@ jobs:
OS: ${{ matrix.os }}
REF: ${{ inputs.tag }}
TARGET: ${{ matrix.target }}
MSI_VERSION: ${{ inputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# REF: https://github.com/marketplace/actions/gh-release