From 4bd8b6ca95b89dd351ac6023b9447a1a71d322b5 Mon Sep 17 00:00:00 2001 From: Jesse Mandel Date: Thu, 21 Aug 2025 21:02:49 -0700 Subject: [PATCH] Migrate MyGet script to GH actions (#41583) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Migrate MyGet script to GH actions to automatically build/publish the Bootstrap NuGet package when a release is created * Remove `-NoPackageAnalysis` flag * Use sha-1 for jobs --------- Co-authored-by: Jesse Mandel Co-authored-by: Julien Déramond --- .github/workflows/publish-nuget.yml | 31 +++++++++++++++++++++++++++++ nuget/MyGet.ps1 | 17 ---------------- nuget/bootstrap.nuspec | 2 +- nuget/bootstrap.sass.nuspec | 2 +- 4 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/publish-nuget.yml delete mode 100644 nuget/MyGet.ps1 diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml new file mode 100644 index 0000000000..23af174ab6 --- /dev/null +++ b/.github/workflows/publish-nuget.yml @@ -0,0 +1,31 @@ +name: Publish NuGet Packages + +on: + release: + types: [published] + +jobs: + package-nuget: + runs-on: windows-latest + if: ${{ github.repository == 'twbs/bootstrap' && startsWith(github.event.release.tag_name, 'v') }} + env: + GITHUB_REF_NAME: ${{ github.ref_name }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: Set up NuGet + uses: nuget/setup-nuget@323ab0502cd38fdc493335025a96c8fdb0edc71f # v2.0.1 + with: + nuget-api-key: ${{ secrets.NuGetAPIKey }} + nuget-version: '5.x' + + - name: Pack NuGet packages + shell: pwsh + run: | + $bsversion = $env:GITHUB_REF_NAME.Substring(1) + nuget pack "nuget\bootstrap.nuspec" -Verbosity detailed -NonInteractive -BasePath . -Version $bsversion + nuget pack "nuget\bootstrap.sass.nuspec" -Verbosity detailed -NonInteractive -BasePath . -Version $bsversion + nuget push "bootstrap.$bsversion.nupkg" -Verbosity detailed -NonInteractive -Source "https://api.nuget.org/v3/index.json" + nuget push "bootstrap.sass.$bsversion.nupkg" -Verbosity detailed -NonInteractive -Source "https://api.nuget.org/v3/index.json" diff --git a/nuget/MyGet.ps1 b/nuget/MyGet.ps1 deleted file mode 100644 index 5213b0104e..0000000000 --- a/nuget/MyGet.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# set env vars usually set by MyGet (enable for local testing) -#$env:SourcesPath = '..' -#$env:NuGet = "./nuget.exe" # https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - -$nuget = $env:NuGet - -# parse the version number out of package.json -$bsversionParts = ((Get-Content $env:SourcesPath\package.json) -join "`n" | ConvertFrom-Json).version.split('-', 2) # split the version on the '-' -$bsversion = $bsversionParts[0] - -if ($bsversionParts.Length -gt 1) { - $bsversion += '-' + $bsversionParts[1].replace('.', '').replace('-', '_') # strip out invalid chars from the PreRelease part -} - -# create packages -& $nuget pack "$env:SourcesPath\nuget\bootstrap.nuspec" -Verbosity detailed -NonInteractive -NoPackageAnalysis -BasePath $env:SourcesPath -Version $bsversion -& $nuget pack "$env:SourcesPath\nuget\bootstrap.sass.nuspec" -Verbosity detailed -NonInteractive -NoPackageAnalysis -BasePath $env:SourcesPath -Version $bsversion diff --git a/nuget/bootstrap.nuspec b/nuget/bootstrap.nuspec index 0736553425..a2f0de96cf 100644 --- a/nuget/bootstrap.nuspec +++ b/nuget/bootstrap.nuspec @@ -2,7 +2,7 @@ bootstrap - + 5 Bootstrap CSS The Bootstrap Authors diff --git a/nuget/bootstrap.sass.nuspec b/nuget/bootstrap.sass.nuspec index 20fbdaa79a..cd08cd495b 100644 --- a/nuget/bootstrap.sass.nuspec +++ b/nuget/bootstrap.sass.nuspec @@ -2,7 +2,7 @@ bootstrap.sass - + 5 Bootstrap Sass The Bootstrap Authors -- 2.47.2