-
Notifications
You must be signed in to change notification settings - Fork 2
148 lines (129 loc) · 6.58 KB
/
Copy pathsharpie-publish.yml
File metadata and controls
148 lines (129 loc) · 6.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: 📦 Publish
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
publish-all:
name: 🌍 Publish all packages
runs-on: ubuntu-latest
outputs:
sharpie_version: ${{ steps.published-versions.outputs.sharpie_version }}
ncurses_version: ${{ steps.published-versions.outputs.ncurses_version }}
pdcurses_version: ${{ steps.published-versions.outputs.pdcurses_version }}
pdcursesmod_version: ${{ steps.published-versions.outputs.pdcursesmod_version }}
sharpie_deployed: ${{ steps.published-versions.outputs.sharpie_deployed }}
ncurses_deployed: ${{ steps.published-versions.outputs.ncurses_deployed }}
pdcurses_deployed: ${{ steps.published-versions.outputs.pdcurses_deployed }}
pdcursesmod_deployed: ${{ steps.published-versions.outputs.pdcursesmod_deployed }}
steps:
- name: ☁️ Checkout repository
id: checkout-repository
uses: actions/checkout@v4
- name: ⏯️ Build and Test
id: build-and-test
uses: ./.github/actions/build-and-test
- name: 🍭 Check published versions
id: published-versions
run: |
PROJECTS=(
"Sharpie/Sharpie.csproj;Sharpie-Curses;sharpie"
"NativeLibraries/Sharpie.NativeLibraries.NCurses.csproj;Sharpie-Libs-NCurses;ncurses"
"NativeLibraries/Sharpie.NativeLibraries.PdCurses.csproj;Sharpie-Libs-PdCurses;pdcurses"
"NativeLibraries/Sharpie.NativeLibraries.PdCursesMod.csproj;Sharpie-Libs-PdCursesMod;pdcursesmod"
)
for LIB in "${PROJECTS[@]}"
do
SPLIT=(${LIB//;/ })
LIB_PATH=${SPLIT[0]}
LIB_PKG=${SPLIT[1]}
LIB_MONIKER=${SPLIT[2]}
VERSION=`cat $LIB_PATH | sed -n "s/\s*<OverallVersion>\(.*\)<\/OverallVersion>$/\1/p"`
echo "${LIB_MONIKER}_version=$VERSION" >> $GITHUB_OUTPUT
DEP=`wget -q https://www.nuget.org/api/v2/package/$LIB_PKG/$VERSION -O /dev/null || echo NO`
if [ "$DEP" = "NO" ]; then
echo "${LIB_MONIKER}_deployed=no" >> $GITHUB_OUTPUT
else
echo "${LIB_MONIKER}_deployed=yes" >> $GITHUB_OUTPUT
fi
done
- name: 📦 Publish Sharpie package
id: publish-sharpie
if: steps.published-versions.outputs.sharpie_deployed == 'no'
shell: bash
run: |
dotnet pack ./Sharpie/Sharpie.csproj
dotnet nuget push **/sharpie-curses.*.nupkg -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: 📦 Publish NCurses package
id: publish-ncurses
if: steps.published-versions.outputs.ncurses_deployed == 'no'
shell: bash
run: |
dotnet pack NativeLibraries/Sharpie.NativeLibraries.NCurses.csproj
dotnet nuget push **/sharpie-libs-ncurses.*.nupkg -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: 📦 Publish PDCurses package
id: publish-pdcurses
if: steps.published-versions.outputs.pdcurses_deployed == 'no'
shell: bash
run: |
dotnet pack NativeLibraries/Sharpie.NativeLibraries.PdCurses.csproj
dotnet nuget push **/sharpie-libs-pdcurses.*.nupkg -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: 📦 Publish PDCursesMod package
id: publish-pdcursesmod
if: steps.published-versions.outputs.pdcursesmod_deployed == 'no'
shell: bash
run: |
dotnet pack NativeLibraries/Sharpie.NativeLibraries.PdCursesMod.csproj
dotnet nuget push **/sharpie-libs-pdcursesmod.*.nupkg -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json
summary:
name: ✔︎ Generate summary
runs-on: ubuntu-latest
needs: publish-all
if: ${{ always() }}
steps:
- name: 📝 Create summary
id: create-summary
shell: bash
run: |
# Check if the publish-all job succeeded
if [ "${{ needs.publish-all.result }}" = "success" ]; then
echo "## 📦 Package Upload Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Package | Status | Version |" >> $GITHUB_STEP_SUMMARY
echo "|---------|--------|---------|" >> $GITHUB_STEP_SUMMARY
# Sharpie package
if [ "${{ needs.publish-all.outputs.sharpie_deployed }}" = "no" ]; then
echo "| Sharpie | ✅ Uploaded | ${{ needs.publish-all.outputs.sharpie_version }} |" >> $GITHUB_STEP_SUMMARY
else
echo "| Sharpie | ⏭️ Already published | ${{ needs.publish-all.outputs.sharpie_version }} |" >> $GITHUB_STEP_SUMMARY
fi
# NCurses package
if [ "${{ needs.publish-all.outputs.ncurses_deployed }}" = "no" ]; then
echo "| NCurses | ✅ Uploaded | ${{ needs.publish-all.outputs.ncurses_version }} |" >> $GITHUB_STEP_SUMMARY
else
echo "| NCurses | ⏭️ Already published | ${{ needs.publish-all.outputs.ncurses_version }} |" >> $GITHUB_STEP_SUMMARY
fi
# PDCurses package
if [ "${{ needs.publish-all.outputs.pdcurses_deployed }}" = "no" ]; then
echo "| PDCurses | ✅ Uploaded | ${{ needs.publish-all.outputs.pdcurses_version }} |" >> $GITHUB_STEP_SUMMARY
else
echo "| PDCurses | ⏭️ Already published | ${{ needs.publish-all.outputs.pdcurses_version }} |" >> $GITHUB_STEP_SUMMARY
fi
# PDCursesMod package
if [ "${{ needs.publish-all.outputs.pdcursesmod_deployed }}" = "no" ]; then
echo "| PDCursesMod | ✅ Uploaded | ${{ needs.publish-all.outputs.pdcursesmod_version }} |" >> $GITHUB_STEP_SUMMARY
else
echo "| PDCursesMod | ⏭️ Already published | ${{ needs.publish-all.outputs.pdcursesmod_version }} |" >> $GITHUB_STEP_SUMMARY
fi
else
echo "## ❌ Publish Job Failed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The publish-all job failed with status: **${{ needs.publish-all.result }}**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "This could be due to:" >> $GITHUB_STEP_SUMMARY
echo "- Build failures" >> $GITHUB_STEP_SUMMARY
echo "- Test failures" >> $GITHUB_STEP_SUMMARY
echo "- Publishing errors" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Please check the publish-all job logs for more details." >> $GITHUB_STEP_SUMMARY
fi