Skip to content

Commit 46fbe0a

Browse files
committed
fix: resolve issues with CI/CD process.
1 parent f6921b4 commit 46fbe0a

4 files changed

Lines changed: 102 additions & 34 deletions

File tree

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- name: Checkout release tag
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.ref }}
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: "10.0.x"
24+
dotnet-quality: "preview"
25+
env:
26+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true"
27+
DOTNET_NOLOGO: "true"
28+
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
29+
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: Build and pack NuGet packages
52+
run: pnpm nx run flowthru:pack
53+
54+
- name: Publish to NuGet
55+
run: |
56+
dotnet nuget push "dist/packages/*.nupkg" \
57+
--api-key ${{ secrets.FLOWTHRU_NUGET_API_KEY }} \
58+
--source https://api.nuget.org/v3/index.json \
59+
--skip-duplicate

.github/workflows/release.yml

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI and Release
1+
name: CI
22

33
on:
44
push:
@@ -14,13 +14,12 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
release:
17+
ci:
1818
runs-on: ubuntu-latest
1919
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, 'chore(release)')"
2020

2121
permissions:
2222
contents: write
23-
packages: write
2423

2524
steps:
2625
- name: Checkout code
@@ -76,7 +75,11 @@ jobs:
7675
REPORTGENERATOR_LICENSE: ${{ secrets.REPORTGENERATOR_LICENSE }}
7776
CI: "true"
7877
run: |
79-
pnpm nx run-many -t test --projects=tag:type:test --output-style=stream \
78+
# Run tests for everything changed since the last release tag.
79+
# Falls back to the first commit if no tags exist yet.
80+
NX_BASE=$(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)
81+
pnpm nx affected -t test --base="${NX_BASE}" --head=HEAD \
82+
--projects=tag:type:test --output-style=stream \
8083
--collect:"XPlat Code Coverage" \
8184
--settings coverlet.runsettings \
8285
--logger "console;verbosity=minimal"
@@ -91,50 +94,57 @@ jobs:
9194
git config user.name "github-actions[bot]"
9295
git config user.email "github-actions[bot]@users.noreply.github.com"
9396
94-
- name: Run NX Release (version + changelog + GitHub Release)
97+
- name: Run NX Release (version + changelog + commit + tag)
9598
id: release
9699
env:
97100
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98101
CI: "true"
99102
run: |
103+
OLD_VERSION=$(node -p "require('./package.json').version")
100104
node scripts/release.mjs
101105
NEW_VERSION=$(node -p "require('./package.json').version")
102106
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
103-
if git diff --quiet HEAD package.json; then
104-
echo "changed=false" >> $GITHUB_OUTPUT
105-
echo "No version bump — skipping publish."
106-
else
107+
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
107108
echo "changed=true" >> $GITHUB_OUTPUT
108-
echo "Version bumped to $NEW_VERSION"
109+
echo "Version bumped from $OLD_VERSION to $NEW_VERSION"
110+
else
111+
echo "changed=false" >> $GITHUB_OUTPUT
112+
echo "No version bump — skipping release."
109113
fi
110114
111-
- name: Build release and pack NuGet packages
112-
if: steps.release.outputs.changed == 'true'
113-
run: pnpm nx run flowthru:pack
114-
115-
- name: Publish to NuGet
116-
if: steps.release.outputs.changed == 'true'
117-
run: |
118-
dotnet nuget push "dist/packages/*.nupkg" \
119-
--api-key ${{ secrets.FLOWTHRU_NUGET_API_KEY }} \
120-
--source https://api.nuget.org/v3/index.json \
121-
--skip-duplicate
122-
123115
- name: Push release commit and tag
124116
if: steps.release.outputs.changed == 'true'
125117
run: git push --follow-tags
126118

127-
- name: Create GitHub Release
119+
- name: Create draft GitHub Release
128120
if: steps.release.outputs.changed == 'true'
129121
env:
130122
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131123
run: |
132-
NEW_VERSION="${{ steps.release.outputs.version }}"
133-
# Extract the section for this version from CHANGELOG.md
134-
NOTES=$(awk "/^## ${NEW_VERSION}/{found=1;next} /^## /{if(found)exit} found{print}" CHANGELOG.md)
135-
gh release create "v${NEW_VERSION}" \
136-
--title "v${NEW_VERSION}" \
137-
--notes "${NOTES}"
124+
VERSION="v${{ steps.release.outputs.version }}"
125+
# Extract the changelog entry for this version
126+
NOTES=$(awk "/^## ${{ steps.release.outputs.version }}/{found=1;next} /^## /{if(found)exit} found{print}" CHANGELOG.md)
127+
gh release create "${VERSION}" \
128+
--title "${VERSION}" \
129+
--notes "${NOTES}" \
130+
--draft
131+
132+
- name: Publish prerelease to NuGet
133+
if: steps.release.outputs.changed == 'true'
134+
env:
135+
FLOWTHRU_NUGET_API_KEY: ${{ secrets.FLOWTHRU_NUGET_API_KEY }}
136+
run: |
137+
VERSION="${{ steps.release.outputs.version }}"
138+
PRERELEASE_VERSION="${VERSION}-preview.${{ github.run_number }}"
139+
# Override version in Directory.Build.props for the prerelease pack only.
140+
# This file was already committed and pushed — this mutation is ephemeral.
141+
sed -i "s|<Version>.*</Version>|<Version>${PRERELEASE_VERSION}</Version>|" Directory.Build.props
142+
pnpm nx run flowthru:pack
143+
sed -i "s|<Version>.*</Version>|<Version>${VERSION}</Version>|" Directory.Build.props
144+
dotnet nuget push "dist/packages/*.nupkg" \
145+
--api-key "${FLOWTHRU_NUGET_API_KEY}" \
146+
--source https://api.nuget.org/v3/index.json \
147+
--skip-duplicate
138148
139149
- name: Upload coverage badges as artifact
140150
if: always()

nx.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"@nx/dotnet"
55
],
66
"targetDefaults": {
7-
"//": "@nx/dotnet infers build with --no-restore but does not add restore as a dependsOn. This default wires it in so restore always runs before build.",
87
"build": {
9-
"dependsOn": ["restore", "^build"]
8+
"dependsOn": [ "restore", "^build" ]
109
}
1110
},
1211
"namedInputs": {
@@ -21,7 +20,6 @@
2120
]
2221
},
2322
"release": {
24-
"//": "NX Release config — versions root package.json (via @nx/js), then release script syncs to Directory.Build.props. tag:nuget projects participate in pack only.",
2523
"projects": [
2624
"flowthru"
2725
],
@@ -73,4 +71,4 @@
7371
}
7472
},
7573
"analytics": false
76-
}
74+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "A type-safe data engineering framework for .NET",
55
"main": "index.js",
66
"scripts": {
7+
"postinstall": "dotnet restore",
78
"prepare": "husky"
89
},
910
"keywords": [
@@ -12,7 +13,7 @@
1213
"kedro",
1314
"dotnet"
1415
],
15-
"author": "Spencer Elkington",
16+
"author": "Chaotic Good Computing",
1617
"license": "Apache-2.0",
1718
"packageManager": "pnpm@10.6.3",
1819
"repository": {

0 commit comments

Comments
 (0)