Skip to content

Commit 8863864

Browse files
Update push-github-n-nuget-packages.yml
Signed-off-by: LUIZ HAMILTON ROBERTO DA SILVA <luizhamilton.lhr@gmail.com>
1 parent 67da0b3 commit 8863864

1 file changed

Lines changed: 29 additions & 15 deletions

File tree

.github/workflows/push-github-n-nuget-packages.yml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
chmod +x nuget.exe
4141
sudo mv nuget.exe /usr/local/bin/nuget
4242
mono --version
43+
xmlstarlet --version
4344
mono /usr/local/bin/nuget help | head -n 1
4445
4546
- name: 📁 Prepare and stage files
@@ -51,7 +52,7 @@ jobs:
5152
for dir in Core-ScriptLibrary BlueTeam-Tools SysAdmin-Tools ITSM-Templates-WKS ITSM-Templates-SVR; do
5253
[ -d "$dir" ] && cp -r "$dir/." "tmp-$pkg/$dir/" || echo "⚠️ Folder $dir not found"
5354
done
54-
cp "$nuspec" "tmp-$pkg/$nuspec"
55+
cp "$nuspec" "tmp-$pkg/$nuspec" || { echo "❌ Failed to copy $nuspec"; echo "skip=true" >> "$GITHUB_OUTPUT"; exit 0; }
5556
cp README.md "tmp-$pkg/$pkg-README.md" || cp Core-ScriptLibrary/README.md "tmp-$pkg/$pkg-README.md" || echo "⚠️ README not found"
5657
cp icon.png "tmp-$pkg/icon.png" || cp Core-ScriptLibrary/icon.png "tmp-$pkg/icon.png" || echo "⚠️ icon.png not found"
5758
cp LICENSE "tmp-$pkg/LICENSE" || cp Core-ScriptLibrary/LICENSE "tmp-$pkg/LICENSE" || {
@@ -68,7 +69,7 @@ jobs:
6869
version=$(xmlstarlet sel -t -m "//metadata/version" -v . "$nuspec")
6970
echo "version=$version" >> "$GITHUB_OUTPUT"
7071
71-
changelog=$(awk "/^## \\[$version\\]/,/^## \\[/" CHANGELOG.md | sed '1d;/^## \\[/d')
72+
changelog=$(awk "/^## \\[$version\\]/,/^## \\[/" CHANGELOG.md | sed '1d;/^## \\[/d' || echo "No changelog found for version $version")
7273
[ -z "$changelog" ] && changelog="No changelog found for version $version"
7374
7475
artifact_url="https://github.com/${{ github.repository }}/packages"
@@ -77,26 +78,38 @@ jobs:
7778
full_notes="$changelog$download_links"
7879
7980
full_notes_escaped=$(echo "$full_notes" | sed \
80-
-e 's/&/\&amp;/g' \
81-
-e 's/</\&lt;/g' \
82-
-e 's/>/\&gt;/g' \
83-
-e 's/"/\&quot;/g' \
84-
-e "s/'/\&apos;/g")
81+
-e 's/&/\&/g' \
82+
-e 's/</\</g' \
83+
-e 's/>/\>/g' \
84+
-e 's/"/\"/g' \
85+
-e "s/'/\'/g")
8586
86-
echo "$full_notes_escaped" > enriched_release_notes.txt
87+
echo "$full_notes_escaped" | iconv -t UTF-8 > enriched_release_notes.txt
8788
echo "notes=$full_notes_escaped" >> "$GITHUB_OUTPUT"
8889
90+
if [ ! -f enriched_release_notes.txt ]; then
91+
echo "❌ enriched_release_notes.txt not found"
92+
exit 1
93+
fi
94+
95+
notes=$(cat enriched_release_notes.txt)
96+
97+
echo "Current .nuspec content:"
98+
cat "$nuspec"
99+
89100
xmlstarlet ed -L \
90-
--var notes "cat('enriched_release_notes.txt')" \
91-
-u "//metadata/releaseNotes" -x '$notes' \
101+
-u "//metadata/releaseNotes" -v "$notes" \
92102
-u "//metadata/tags" -v "powershell itsm sysadmin security gpo automation enterprise activedirectory network wsus configuration sso ldap" \
93103
-u "//metadata/iconUrl" -v "icon.png" \
94104
-s "//metadata[not(repository)]" -t elem -n "repository" -v "" \
95105
-i "//metadata/repository" -t attr -n "type" -v "git" \
96106
-i "//metadata/repository" -t attr -n "url" -v "https://github.com/${{ github.repository }}" \
97107
-i "//metadata/repository" -t attr -n "branch" -v "${{ github.ref_name }}" \
98108
-i "//metadata/repository" -t attr -n "commit" -v "${{ github.sha }}" \
99-
"$nuspec"
109+
"$nuspec" || { echo "❌ xmlstarlet failed to update $nuspec"; exit 1; }
110+
111+
echo "Updated .nuspec content:"
112+
cat "$nuspec"
100113
101114
- name: 📦 Pack NuGet package
102115
if: steps.prepare.outputs.skip != 'true'
@@ -112,9 +125,9 @@ jobs:
112125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113126
run: |
114127
for pkg in nupkg-out/*.nupkg nupkg-out/*.snupkg; do
115-
mono /usr/local/bin/nuget push "$pkg" \
128+
[ -f "$pkg" ] && mono /usr/local/bin/nuget push "$pkg" \
116129
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
117-
-ApiKey "$GITHUB_TOKEN" -NonInteractive -SkipDuplicate
130+
-ApiKey "$GITHUB_TOKEN" -NonInteractive -SkipDuplicate || echo "⚠️ No packages found or push skipped"
118131
done
119132
120133
- name: 🚀 Push to NuGet.org
@@ -123,9 +136,9 @@ jobs:
123136
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
124137
run: |
125138
for pkg in nupkg-out/*.nupkg nupkg-out/*.snupkg; do
126-
mono /usr/local/bin/nuget push "$pkg" \
139+
[ -f "$pkg" ] && mono /usr/local/bin/nuget push "$pkg" \
127140
-Source "https://api.nuget.org/v3/index.json" \
128-
-ApiKey "$NUGET_API_KEY" -NonInteractive -SkipDuplicate
141+
-ApiKey "$NUGET_API_KEY" -NonInteractive -SkipDuplicate || echo "⚠️ No packages found or push skipped"
129142
done
130143
131144
- name: 🏷️ Create Git tag
@@ -143,3 +156,4 @@ jobs:
143156
if: always()
144157
run: |
145158
rm -rf tmp-ITSMAndSysAdminTools ReadmeCopies nupkg-out enriched_release_notes.txt || true
159+

0 commit comments

Comments
 (0)