]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Migrate MyGet script to GH actions (#41583) main
authorJesse Mandel <jesse.mandel@gmail.com>
Fri, 22 Aug 2025 04:02:49 +0000 (21:02 -0700)
committerGitHub <noreply@github.com>
Fri, 22 Aug 2025 04:02:49 +0000 (21:02 -0700)
* 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 <jesse.mandel@jdpa.com>
Co-authored-by: Julien Déramond <juderamond@gmail.com>
.github/workflows/publish-nuget.yml [new file with mode: 0644]
nuget/MyGet.ps1 [deleted file]
nuget/bootstrap.nuspec
nuget/bootstrap.sass.nuspec

diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml
new file mode 100644 (file)
index 0000000..23af174
--- /dev/null
@@ -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 (file)
index 5213b01..0000000
+++ /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
index 073655342515b4edc0562d77793ba828fee044c5..a2f0de96cfe25b715b6672699b7d759651151835 100644 (file)
@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
   <metadata>
     <id>bootstrap</id>
-    <!-- pulled from package.json -->
+    <!-- pulled from release tag -->
     <version>5</version>
     <title>Bootstrap CSS</title>
     <authors>The Bootstrap Authors</authors>
index 20fbdaa79a50b9ff158f6a7c9c98f4435ca10533..cd08cd495bec4036544783358edaca438da3b6f7 100644 (file)
@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
   <metadata>
     <id>bootstrap.sass</id>
-    <!-- pulled from package.json -->
+    <!-- pulled from release tag -->
     <version>5</version>
     <title>Bootstrap Sass</title>
     <authors>The Bootstrap Authors</authors>