Skip to content

Commit 243ddcb

Browse files
SonOfSardaarGurpreet Singh
andauthored
fix change detection (#294)
* Remove appveyor pipeline files as we are using github actions now add CODEOWNERS file Add steps to identify change path so that we can publish nuget based on changed project * test if path changes are detected as expected * change a file to trigger and test samples project change detection variable * add conditions to when a package should be created * allow change detection with reference to base * add check if any nugets should be published * add option to publish all packages if needed * use latest tag for base --------- Co-authored-by: Gurpreet Singh <[email protected]>
1 parent 8c3eb68 commit 243ddcb

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,23 @@ on:
1010
default: false
1111
type: boolean
1212

13+
publishWhichNuget:
14+
description: 'Which Nuget ?'
15+
required: true
16+
default: 'Only Changed'
17+
type: choice
18+
options:
19+
- Only Changed
20+
- All
21+
1322
jobs:
1423
build:
1524
runs-on: ubuntu-latest
1625
outputs:
1726
semver: ${{ steps.gitversion.outputs.semVer }}
1827
fullsemver: ${{ steps.gitversion.outputs.fullSemVer }}
1928
nugetversion: ${{ steps.gitversion.outputs.fullSemVer }}
20-
29+
publishNuget: ${{ steps.changes.outputs.BddfyUpdated == 'true' || steps.changes.outputs.SamplesUpdated == 'true' || github.event.inputs.publishWhichNuget == 'All' }}
2130
steps:
2231
- name: Checkout code
2332
uses: actions/checkout@v5
@@ -147,13 +156,15 @@ jobs:
147156
- name: Check for changes in project paths
148157
id: changes
149158
run: |
150-
if git diff --quiet origin/main HEAD -- src/Samples/; then
159+
latestTag=$(git describe --tags --abbrev=0)
160+
161+
if git diff --quiet "$latestTag" HEAD -- src/Samples/; then
151162
echo "SamplesUpdated=false" >> $GITHUB_OUTPUT
152163
else
153164
echo "SamplesUpdated=true" >> $GITHUB_OUTPUT
154165
fi
155166
156-
if git diff --quiet origin/main HEAD -- src/TestStack.BDDfy/; then
167+
if git diff --quiet "$latestTag" HEAD -- src/TestStack.BDDfy/; then
157168
echo "BddfyUpdated=false" >> $GITHUB_OUTPUT
158169
else
159170
echo "BddfyUpdated=true" >> $GITHUB_OUTPUT
@@ -166,7 +177,7 @@ jobs:
166177
167178
- name: Create Samples package
168179
working-directory: src
169-
if: steps.changes.outputs.SamplesUpdated == 'true'
180+
if: steps.changes.outputs.SamplesUpdated == 'true' || github.event.inputs.publishWhichNuget == 'All'
170181
run: >-
171182
dotnet pack ./Samples/TestStack.BDDfy.Samples/*.csproj
172183
--configuration Release
@@ -176,7 +187,7 @@ jobs:
176187
177188
- name: Create Bddfy package
178189
working-directory: src
179-
if: steps.changes.outputs.BddfyUpdated == 'true'
190+
if: steps.changes.outputs.BddfyUpdated == 'true' || github.event.inputs.publishWhichNuget == 'All'
180191
run: >-
181192
dotnet pack ./TestStack.BDDfy/*.csproj
182193
--configuration Release
@@ -199,7 +210,7 @@ jobs:
199210
publish-nuget:
200211
runs-on: ubuntu-latest
201212
needs: build
202-
if: github.event.inputs.runPublish == 'true' || github.ref_name == github.event.repository.default_branch
213+
if: needs.build.outputs.publishNuget == 'true' && (github.event.inputs.runPublish == 'true' || github.ref_name == github.event.repository.default_branch)
203214
environment:
204215
name: Publish
205216
url: https://www.nuget.org/packages/TestStack.BDDfy/

0 commit comments

Comments
 (0)