From cec0dcaa58f7f2392a08e1f97fc59a9ccd16b3e7 Mon Sep 17 00:00:00 2001 From: "Michael J. Currie" Date: Mon, 23 Sep 2019 10:46:50 -0500 Subject: [PATCH] add versioning and pipeline --- CHANGELOG.md | 0 ...ieTechnologies.Razor.PageVisibility.csproj | 2 - azure-pipelines.yml | 230 ++++++++++++++++++ versioning.ps1 | 17 ++ 4 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 azure-pipelines.yml create mode 100644 versioning.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/CurrieTechnologies.Razor.PageVisibility.csproj b/CurrieTechnologies.Razor.PageVisibility.csproj index 8cf5519..34c2431 100644 --- a/CurrieTechnologies.Razor.PageVisibility.csproj +++ b/CurrieTechnologies.Razor.PageVisibility.csproj @@ -4,7 +4,6 @@ netstandard2.0 3.0 true - 0.4.0 Michael J. Currie Currie Technologies Razor.PageVisibility @@ -22,7 +21,6 @@ Update to .NET Core 3.0 Preview 9 - true diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..400c351 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,230 @@ +trigger: + - master + - develop + - release/* + +pr: + - master + - develop + - release/* + +variables: + buildConfiguration: "Release" + YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn + +stages: + - stage: buildStage + displayName: Build + jobs: + - job: lintLibrary + displayName: Lint + pool: + vmImage: "windows-latest" + steps: + - task: CacheBeta@1 + inputs: + key: "yarn | $(Agent.OS) | yarn.lock" + path: "$(YARN_CACHE_FOLDER)" + displayName: Cache Yarn Packages + + - task: YarnInstaller@3 + displayName: "Installing Yarn 1.17.x" + inputs: + versionSpec: 1.17.x + checkLatest: true + includePrerelease: false + + - task: Yarn@3 + displayName: "Installing Yarn Packages" + inputs: + arguments: --frozen-lockfile + + - task: Yarn@3 + displayName: "Linting" + inputs: + arguments: lint + + - task: Yarn@3 + displayName: "Checking Prettier" + inputs: + arguments: prettier:check + + - task: Yarn@3 + displayName: "Checking Types" + inputs: + arguments: build:tsc + + - job: buildLibrary + displayName: Build + dependsOn: + pool: + vmImage: "windows-latest" + steps: + - task: PowerShell@2 + displayName: "Setting build number" + inputs: + filePath: "./versioning.ps1" + + - task: CacheBeta@1 + inputs: + key: "yarn | $(Agent.OS) | yarn.lock" + path: "$(YARN_CACHE_FOLDER)" + displayName: Cache Yarn Packages + + - task: YarnInstaller@3 + displayName: "Installing Yarn 1.17.x" + inputs: + versionSpec: 1.17.x + checkLatest: true + includePrerelease: false + + - task: Yarn@3 + displayName: "Installing Yarn Packages" + inputs: + arguments: --frozen-lockfile + + - task: Yarn@3 + displayName: "Building JS and CSS" + inputs: + arguments: build + + - task: DotNetCoreInstaller@1 + displayName: "Installing .NET Core SDK..." + inputs: + packageType: "sdk" + version: "3.0.100-rc1-014190" + + - task: DotNetCoreCLI@2 + displayName: "Restoring Nuget Packages" + inputs: + command: "restore" + projects: "**/*.csproj" + feedsToUse: "select" + verbosityRestore: "Normal" + + - task: DotNetCoreCLI@2 + displayName: "Building" + inputs: + command: "build" + projects: "**/*.csproj" + arguments: "-c $(buildConfiguration)" + + - task: DotNetCoreCLI@2 + displayName: "Packing" + inputs: + command: "pack" + packagesToPack: "**/*.csproj" + versioningScheme: "byBuildNumber" + verbosityPack: "Normal" + + - task: CopyFiles@2 + displayName: "Copying CHANGELOG" + inputs: + Contents: "CHANGELOG.md" + TargetFolder: "$(Build.ArtifactStagingDirectory)" + + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: "$(Build.ArtifactStagingDirectory)" + ArtifactName: "drop" + publishLocation: "Container" + + - stage: deployStage + displayName: Deploy + dependsOn: buildStage + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.Reason'], 'IndividualCI')) + jobs: + - deployment: githubRelease + displayName: Create Github Release + pool: + vmImage: "windows-latest" + environment: currietechnologies-prod + strategy: + runOnce: + deploy: + steps: + - task: DownloadBuildArtifacts@0 + displayName: Download Build Artifacts + inputs: + buildType: "current" + downloadType: "single" + artifactName: "drop" + downloadPath: "$(System.ArtifactStagingDirectory)" + + - task: GitHubRelease@1 + displayName: Create GitHub Release + inputs: + gitHubConnection: "github connection 1" + repositoryName: "$(Build.Repository.Name)" + action: "create" + target: "$(Build.SourceVersion)" + tagSource: "userSpecifiedTag" + tag: "v$(Build.BuildNumber)" + title: "v$(Build.BuildNumber)" + releaseNotesFilePath: "$(System.ArtifactStagingDirectory)/drop/CHANGELOG.md" + assets: "$(System.ArtifactStagingDirectory)/drop/*.nupkg" + changeLogCompareToRelease: "lastFullRelease" + changeLogType: "commitBased" + + - deployment: privateNuget + displayName: Push to Private NuGet Feed + pool: + vmImage: "windows-latest" + environment: currietechnologies-prod + strategy: + runOnce: + deploy: + steps: + - task: DownloadBuildArtifacts@0 + displayName: Download Build Artifacts + inputs: + buildType: "current" + downloadType: "single" + artifactName: "drop" + downloadPath: "$(System.ArtifactStagingDirectory)" + + - task: NuGetToolInstaller@1 + displayName: Use Latest NuGet + inputs: + versionSpec: "5.x" + checkLatest: true + + - task: DotNetCoreCLI@2 + displayName: "Push to Private NuGet Feed" + inputs: + command: "push" + packagesToPush: "$(System.ArtifactStagingDirectory)/drop/*.nupkg" + nuGetFeedType: "internal" + publishVstsFeed: "92bb098c-7077-481e-813d-9c0d49ec780d" + + - deployment: publicNuget + displayName: Push to NuGet.org + pool: + vmImage: "windows-latest" + environment: currietechnologies-prod + strategy: + runOnce: + deploy: + steps: + - task: DownloadBuildArtifacts@0 + displayName: Download Build Artifacts + inputs: + buildType: "current" + downloadType: "single" + artifactName: "drop" + downloadPath: "$(System.ArtifactStagingDirectory)" + + - task: NuGetToolInstaller@1 + displayName: Use Latest NuGet + inputs: + versionSpec: "5.x" + checkLatest: true + + - task: NuGetCommand@2 + displayName: Push to NuGet.org + inputs: + command: "push" + packagesToPush: "$(System.ArtifactStagingDirectory)/drop/*.nupkg" + nuGetFeedType: "external" + publishFeedCredentials: "NuGet All" + verbosityPush: "Normal" \ No newline at end of file diff --git a/versioning.ps1 b/versioning.ps1 new file mode 100644 index 0000000..09251b1 --- /dev/null +++ b/versioning.ps1 @@ -0,0 +1,17 @@ +$pkgPath = "$Env:BUILD_SOURCESDIRECTORY\package.json"; +$pkg = Get-Content "$pkgPath" | Out-String | ConvertFrom-Json +$version = $pkg.version; +$buildNumber = $Env:BUILD_BUILDNUMBER; +$branchName = $Env:BUILD_SOURCEBRANCHNAME +$branch = $Env:BUILD_SOURCEBRANCH +$buildReason = $Env:BUILD_REASON + +If ($buildReason -eq "IndividualCI" -and $branch -eq "refs/heads/master") { + Write-Host "##vso[build.updatebuildnumber]$version" +} +ElseIf ($buildReason -eq "PullRequest") { + Write-Host "##vso[build.updatebuildnumber]$version-pr-$buildNumber" +} +Else { + Write-Host "##vso[build.updatebuildnumber]$version-$branchName-$buildNumber" +} \ No newline at end of file