Skip to content

Commit e391694

Browse files
authored
Merge pull request #14591 from vzarytovskii/check-packages-version
2 parents 30508ef + a9babad commit e391694

5 files changed

+66
-0
lines changed

azure-pipelines.yml

+32
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,38 @@ stages:
264264
DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1
265265
displayName: Check code formatting (run 'dotnet fantomas src -r' to fix)
266266

267+
# Check whether package with current version has been published to nuget.org
268+
# We will try to restore both FSharp.Core and FCS and if restore is _successful_, package version needs to be bumped.
269+
# NOTE: This CI check should only run on the release branches.
270+
- job: Check_Published_Package_Versions
271+
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), or(startsWith(variables['System.PullRequest.SourceBranch'], 'release/dev'), startsWith(variables['System.PullRequest.TargetBranch'], 'release/dev')))
272+
pool:
273+
vmImage: $(UbuntuMachineQueueName)
274+
strategy:
275+
maxParallel: 2
276+
matrix:
277+
FCS:
278+
_project: "FSharp.Compiler.Service_notshipped.fsproj"
279+
FSCore:
280+
_project: "FSharp.Core_notshipped.fsproj"
281+
steps:
282+
- checkout: self
283+
clean: true
284+
- task: UseDotNet@2
285+
displayName: install SDK
286+
inputs:
287+
packageType: sdk
288+
useGlobalJson: true
289+
includePreviewVersions: true
290+
workingDirectory: $(Build.SourcesDirectory)
291+
installationPath: $(Agent.ToolsDirectory)/dotnet
292+
- pwsh: ./check.ps1 -project $(_project)
293+
workingDirectory: $(Build.SourcesDirectory)/buildtools/checkpackages
294+
env:
295+
DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1
296+
displayName: Check published package version
297+
298+
267299
#-------------------------------------------------------------------------------------------------------------------#
268300
# PR builds #
269301
#-------------------------------------------------------------------------------------------------------------------#
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<Project>
2+
23
</Project>

buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj

+8
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@
2020
<PackageReference Include="FSharp.Compiler.Service" Version="[$(FSharpCompilerServicePackageVersion)]" />
2121
</ItemGroup>
2222

23+
<Target Name="WritePackageVersion" BeforeTargets="Restore">
24+
<WriteLinesToFile
25+
File="Version.txt"
26+
Lines="FSharp.Compiler.Service=$(FSharpCompilerServicePackageVersion)"
27+
Overwrite="true"
28+
Encoding="Unicode"/>
29+
</Target>
30+
2331
</Project>

buildtools/checkpackages/FSharp.Core_notshipped.fsproj

+8
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@
1414
<PackageReference Include="FSharp.Core" Version="[$(FSCorePackageVersionValue)]" />
1515
</ItemGroup>
1616

17+
<Target Name="WritePackageVersion" BeforeTargets="Restore">
18+
<WriteLinesToFile
19+
File="Version.txt"
20+
Lines="FSharp.Core=$(FSCorePackageVersionValue)"
21+
Overwrite="true"
22+
Encoding="Unicode"/>
23+
</Target>
24+
1725
</Project>

buildtools/checkpackages/check.ps1

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ENTRY POINT MAIN()
2+
Param(
3+
[Parameter(Mandatory=$True)]
4+
[String] $project
5+
)
6+
& dotnet restore $project 2>$null
7+
8+
if ($LASTEXITCODE -eq 0)
9+
{
10+
$package = Get-Content -Path .\Version.txt
11+
Write-Error "
12+
Package restore succeded for '${package}', expected to fail.
13+
This usually means that the package has been already published.
14+
Please, bump the version to fix this failure." -ErrorAction Stop
15+
} else {
16+
exit 0
17+
}

0 commit comments

Comments
 (0)