Skip to content

Commit cf0bb18

Browse files
committed
fix: further CI/CD enhancements for nuget flow
1 parent f92f512 commit cf0bb18

2 files changed

Lines changed: 36 additions & 51 deletions

File tree

.github/workflows/publish.yml

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ jobs:
1212
contents: read
1313

1414
steps:
15-
- name: Checkout release tag
16-
uses: actions/checkout@v4
17-
with:
18-
ref: ${{ github.ref }}
19-
2015
- name: Setup .NET
2116
uses: actions/setup-dotnet@v4
2217
with:
@@ -27,36 +22,15 @@ jobs:
2722
DOTNET_NOLOGO: "true"
2823
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
2924

30-
- name: Setup Node.js
31-
uses: actions/setup-node@v4
32-
with:
33-
node-version: "22"
34-
35-
- name: Setup pnpm
36-
uses: pnpm/action-setup@v4
37-
with:
38-
version: 10.6.3
39-
40-
- name: Cache NuGet packages
41-
uses: actions/cache@v4
42-
with:
43-
path: ~/.nuget/packages
44-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json', '**/*.csproj') }}
45-
restore-keys: |
46-
${{ runner.os }}-nuget-
47-
48-
- name: Install dependencies
49-
run: pnpm install
50-
51-
- name: Stamp release version into Directory.Build.props
25+
- name: Download NuGet packages from release
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5228
run: |
53-
VERSION="${{ github.ref_name }}"
54-
VERSION="${VERSION#v}"
55-
sed -i "s|<Version>.*</Version>|<Version>${VERSION}</Version>|" Directory.Build.props
56-
echo "Stamped version: ${VERSION}"
57-
58-
- name: Build and pack NuGet packages
59-
run: pnpm nx run-many -t pack
29+
mkdir -p dist/packages
30+
gh release download "${{ github.ref_name }}" \
31+
--pattern "*.nupkg" \
32+
--dir dist/packages \
33+
--repo "${{ github.repository }}"
6034
6135
- name: Publish to NuGet
6236
run: |

.github/workflows/release.yml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,34 @@ jobs:
170170
--notes "${NOTES}" \
171171
--draft
172172
173+
- name: Pack NuGet packages (release version)
174+
if: steps.release.outputs.changed == 'true'
175+
run: pnpm nx run-many -t pack
176+
177+
- name: Upload packages to GitHub release
178+
if: steps.release.outputs.changed == 'true'
179+
env:
180+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
181+
run: |
182+
VERSION="v${{ steps.release.outputs.version }}"
183+
gh release upload "${VERSION}" dist/packages/*.nupkg
184+
185+
- name: Publish preview to NuGet
186+
if: steps.release.outputs.changed == 'true'
187+
env:
188+
FLOWTHRU_NUGET_API_KEY: ${{ secrets.FLOWTHRU_NUGET_API_KEY }}
189+
run: |
190+
VERSION="${{ steps.release.outputs.version }}"
191+
PRERELEASE_VERSION="${VERSION}-preview.${{ github.run_number }}"
192+
sed -i "s|<Version>.*</Version>|<Version>${PRERELEASE_VERSION}</Version>|" Directory.Build.props
193+
rm dist/packages/*.nupkg
194+
pnpm nx run-many -t pack
195+
sed -i "s|<Version>.*</Version>|<Version>${VERSION}</Version>|" Directory.Build.props
196+
dotnet nuget push "dist/packages/*.nupkg" \
197+
--api-key "${FLOWTHRU_NUGET_API_KEY}" \
198+
--source https://api.nuget.org/v3/index.json \
199+
--skip-duplicate
200+
173201
- name: Install Copilot CLI
174202
if: steps.release.outputs.changed == 'true'
175203
run: npm install -g @github/copilot
@@ -218,23 +246,6 @@ jobs:
218246
gh release edit "${VERSION}" --notes-file /tmp/combined-notes.md
219247
fi
220248
221-
- name: Publish prerelease to NuGet
222-
if: steps.release.outputs.changed == 'true'
223-
env:
224-
FLOWTHRU_NUGET_API_KEY: ${{ secrets.FLOWTHRU_NUGET_API_KEY }}
225-
run: |
226-
VERSION="${{ steps.release.outputs.version }}"
227-
PRERELEASE_VERSION="${VERSION}-preview.${{ github.run_number }}"
228-
# Override version in Directory.Build.props for the prerelease pack only.
229-
# This file was already committed and pushed — this mutation is ephemeral.
230-
sed -i "s|<Version>.*</Version>|<Version>${PRERELEASE_VERSION}</Version>|" Directory.Build.props
231-
pnpm nx run-many -t pack
232-
sed -i "s|<Version>.*</Version>|<Version>${VERSION}</Version>|" Directory.Build.props
233-
dotnet nuget push "dist/packages/*.nupkg" \
234-
--api-key "${FLOWTHRU_NUGET_API_KEY}" \
235-
--source https://api.nuget.org/v3/index.json \
236-
--skip-duplicate
237-
238249
- name: Upload coverage badges as artifact
239250
if: always()
240251
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)