Update nuspec-generator.ps1 #175
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish NuGet Package to GitHub | |
on: | |
push: | |
branches: [main] | |
release: | |
types: [published, prerelease] | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
publish-nuget: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🧾 Checkout repository | |
uses: actions/checkout@v4.2.2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: 📦 Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y mono-complete xmlstarlet | |
wget -O nuget.exe https://dist.nuget.org/win-x86-commandline/v6.11.0/nuget.exe | |
chmod +x nuget.exe | |
sudo mv nuget.exe /usr/local/bin/nuget | |
- name: 📁 Prepare and stage files | |
run: | | |
pkg="sysadmin-prosuite" | |
nuspec="$pkg.nuspec" | |
mkdir -p nupkg-out "tmp-$pkg" | |
# Copy each directory if it exists | |
for dir in BlueTeam-Tools Core-ScriptLibrary ITSM-Templates-SVR ITSM-Templates-WKS SysAdmin-Tools; do | |
if [ -d "$dir" ]; then | |
cp -r "$dir/." "tmp-$pkg/$dir/" | |
fi | |
done | |
# Copy required metadata and assets | |
cp "$nuspec" "tmp-$pkg/$pkg.nuspec" | |
cp README.md "tmp-$pkg/README.md" || { echo "::error file=README.md::README.md not found"; exit 1; } | |
cp LICENSE.txt "tmp-$pkg/LICENSE.txt" || { echo "::error file=LICENSE.txt::LICENSE.txt not found"; exit 1; } | |
cp icon.png "tmp-$pkg/icon.png" || true | |
- name: 🛠️ Pack NuGet package | |
run: | | |
pkg="sysadmin-prosuite" | |
cd "tmp-$pkg" | |
mono /usr/local/bin/nuget pack "$pkg.nuspec" \ | |
-OutputDirectory ../nupkg-out \ | |
-NonInteractive | |
- name: 🚀 Push to GitHub Packages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
for pkg_path in nupkg-out/*.nupkg; do | |
if [ -f "$pkg_path" ]; then | |
mono /usr/local/bin/nuget push "$pkg_path" \ | |
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ | |
-ApiKey "$GITHUB_TOKEN" \ | |
-NonInteractive \ | |
-SkipDuplicate | |
fi | |
done | |
- name: 🧹 Clean up | |
if: always() | |
run: | | |
rm -rf "tmp-sysadmin-prosuite" nupkg-out || true |