Skip to content

Commit 7547c80

Browse files
committed
Work CD-CI
- Improve PS for dependecies update. Signed-off-by: José Simões <[email protected]>
1 parent 2eb1844 commit 7547c80

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

update-dependencies.ps1

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,19 @@ else
9494
$packageName = $package[0]
9595
$packageOriginVersion = $package[1]
9696

97-
# update package
98-
if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*')
97+
# update package, only on the first pass
98+
if($updatePackageOutput -eq $null)
9999
{
100-
# don't allow prerelease for release and master branches
101-
$updatePackage = nuget update $solutionFile[0].FullName -Source https://api.nuget.org/v3/index.json -Source https://api.nuget.org/v3/index.json
102-
}
103-
else
104-
{
105-
# allow prerelease for all others
106-
$updatePackage = nuget update $solutionFile[0].FullName -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json -PreRelease
100+
if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*')
101+
{
102+
# don't allow prerelease for release and master branches
103+
$updatePackageOutput = nuget update $solutionFile[0].FullName -Source https://api.nuget.org/v3/index.json -Source https://api.nuget.org/v3/index.json
104+
}
105+
else
106+
{
107+
# allow prerelease for all others
108+
$updatePackageOutput = nuget update $solutionFile[0].FullName -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json -PreRelease
109+
}
107110
}
108111

109112
# need to get target version
@@ -121,6 +124,18 @@ else
121124
}
122125
}
123126

127+
# sanity check
128+
if($packageTargetVersion -eq $packageOriginVersion)
129+
{
130+
"$packageName has the same version as before: $packageOriginVersion." | Write-Host -ForegroundColor White -BackgroundColor Red
131+
132+
throw "$packageName has the same version as before: $packageOriginVersion."
133+
}
134+
else
135+
{
136+
"Bumping $packageName from $packageOriginVersion to $packageTargetVersion." | Write-Host -ForegroundColor Cyan
137+
}
138+
124139
# find csproj
125140
$projectPath = (Get-ChildItem -Path ".\" -Include "*.csproj" -Recurse)
126141

@@ -170,6 +185,9 @@ else
170185

171186
# build PR title
172187
$prTitle = "Bumps $packageName from $packageOriginVersion to $packageTargetVersion"
188+
189+
#clear
190+
$updatePackageOutput = $null
173191
}
174192

175193
# rename csproj files back to nfproj
@@ -195,13 +213,15 @@ else
195213
# commit changes
196214
git add -A 2>&1
197215

216+
$packageCount = $packageList.length
217+
198218
# commit message with a different title if one or more dependencies are updated
199219
if ($packageList.length -gt 1)
200220
{
201-
git commit -m "Update $packageList.length NuGet dependencies" -m"$commitMessage" -q
221+
git commit -m "Update $packageCount NuGet dependencies" -m"$commitMessage" -q
202222

203223
# fix PR title
204-
$prTitle = "Update $packageList.length NuGet dependencies"
224+
$prTitle = "Update $packageCount NuGet dependencies"
205225
}
206226
else
207227
{
@@ -211,7 +231,7 @@ else
211231
git push --set-upstream origin $newBranchName --porcelain -q
212232

213233
# start PR
214-
# we are hardcoding to develop branch to have a fixed one
234+
# we are hardcoding to 'develop' branch to have a fixed one
215235
# this is very important for tags (which don't have branch information)
216236
# considering that the base branch can be changed at the PR ther is no big deal about this
217237
$prRequestBody = @{title="$prTitle";body="$commitMessage";head="$newBranchName";base="develop"} | ConvertTo-Json

0 commit comments

Comments
 (0)