1- name : CI and Release
1+ name : CI
22
33on :
44 push :
@@ -14,13 +14,12 @@ concurrency:
1414 cancel-in-progress : true
1515
1616jobs :
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
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()
0 commit comments