Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GitHub releases for merges into main #2628

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 176 additions & 160 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
parameters:
- name: testProjects
type: object
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because this pipeline hasn't run unit tests in years.

default:
- OmniSharp.DotNetTest.Tests
- OmniSharp.MSBuild.Tests,OmniSharp.Roslyn.CSharp.Tests,OmniSharp.Cake.Tests,OmniSharp.Script.Tests,OmniSharp.Stdio.Tests,OmniSharp.Http.Tests,OmniSharp.Tests,OmniSharp.Lsp.Tests

trigger:
batch: "true"
branches:
include:
- master
- refs/tags/*

pr:
autoCancel: "true"
branches:
include:
- master
- feature/*
paths:
exclude:
- 'CHANGELOG.md'
pr: none

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a "build" pipeline in GH actions which performs the same steps that this pipeline did for PRs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch protections rules have been updated accordingly.

resources:
repositories:
Expand All @@ -42,152 +27,183 @@ variables:
Artifacts: $(Build.SourcesDirectory)/artifacts/
VstsArtifacts: "$(Artifacts)"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true"
IsMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
IsRelease: $[startsWith(variables['Build.SourceBranch'], 'refs/tags/v')]
IsBetaRelease: $[and(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), contains(variables['Build.SourceBranch'], '-beta.'))]
IsOfficialRelease: $[and(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), not(contains(variables['Build.SourceBranch'], '-beta.')))]

stages:
- stage: CreateBetaReleaseTag
displayName: "Tag Beta Release"
condition: eq(variables.IsMaster, true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running against master branch no longer builds artifacts directly. Instead it creates a draft release and tag which will then cause this pipeline to build a prerelease.

jobs:
- job: GitVersion
pool:
vmImage: "windows-2019"
steps:
- template: gitversion/store.yml@rsg
parameters:
NuGetVersion: $(NuGetVersion)
version: $(GitVersionVersion)

- job: CreateTag
pool:
vmImage: "ubuntu-latest"
dependsOn: GitVersion
steps:
- template: ./.pipelines/init.yml
parameters:
Verbosity: $(Verbosity)
CakeVersion: $(CakeVersion)
DotNetVersion: $(DotNetVersion)
NuGetVersion: $(NuGetVersion)
- task: GitHubRelease@1
displayName: "GitHub create beta release"
inputs:
gitHubConnection: github
repositoryName: OmniSharp/omnisharp-roslyn
action: create
tag: "v$(GitVersion.SemVer)"
title: "v$(GitVersion.SemVer)"
isDraft: true
isPreRelease: true
addChangeLog: true

jobs:
- job: GitVersion
pool:
vmImage: "windows-2019"
steps:
- template: gitversion/store.yml@rsg
parameters:
NuGetVersion: $(NuGetVersion)
version: $(GitVersionVersion)
- stage: BuildRelease
displayName: "Build Release"
condition: eq(variables.IsRelease, true)
jobs:
- job: GitVersion
pool:
vmImage: "windows-2019"
steps:
- template: gitversion/store.yml@rsg
parameters:
NuGetVersion: $(NuGetVersion)
version: $(GitVersionVersion)

- job: macOS
pool:
vmImage: "macos-12"
dependsOn: GitVersion
steps:
- template: ./.pipelines/init.yml
parameters:
Verbosity: $(Verbosity)
CakeVersion: $(CakeVersion)
DotNetVersion: $(DotNetVersion)
NuGetVersion: $(NuGetVersion)
MonoVersion: $(MonoVersion)
- script: |
echo $PATH
chmod 755 ./build.sh
./build.sh --configuration Release --verbosity Verbose --target CI --publish-all --archive
displayName: "Build"
- template: ./.pipelines/artifacts.yml
parameters:
Artifacts: $(Artifacts)
- job: macOS
pool:
vmImage: "macos-12"
dependsOn: GitVersion
steps:
- template: ./.pipelines/init.yml
parameters:
Verbosity: $(Verbosity)
CakeVersion: $(CakeVersion)
DotNetVersion: $(DotNetVersion)
NuGetVersion: $(NuGetVersion)
MonoVersion: $(MonoVersion)
- script: |
echo $PATH
chmod 755 ./build.sh
./build.sh --configuration Release --verbosity Verbose --target CI --publish-all --archive
displayName: "Build"
- template: ./.pipelines/artifacts.yml
parameters:
Artifacts: $(Artifacts)

- job: Linux
pool:
vmImage: "ubuntu-20.04"
dependsOn: GitVersion
steps:
- template: ./.pipelines/init.yml
parameters:
Verbosity: $(Verbosity)
CakeVersion: $(CakeVersion)
DotNetVersion: $(DotNetVersion)
NuGetVersion: $(NuGetVersion)
MonoVersion: $(MonoVersion)
- script: |
chmod 755 ./build.sh
./build.sh --configuration Release --verbosity Verbose --target CI --publish-all --archive
displayName: "Build"
- template: ./.pipelines/artifacts.yml
parameters:
Artifacts: $(Artifacts)
- job: Linux
pool:
vmImage: "ubuntu-20.04"
dependsOn: GitVersion
steps:
- template: ./.pipelines/init.yml
parameters:
Verbosity: $(Verbosity)
CakeVersion: $(CakeVersion)
DotNetVersion: $(DotNetVersion)
NuGetVersion: $(NuGetVersion)
MonoVersion: $(MonoVersion)
- script: |
chmod 755 ./build.sh
./build.sh --configuration Release --verbosity Verbose --target CI --publish-all --archive
displayName: "Build"
- template: ./.pipelines/artifacts.yml
parameters:
Artifacts: $(Artifacts)

- job: Windows
pool:
vmImage: "windows-2022"
dependsOn: GitVersion
steps:
- template: ./.pipelines/init.yml
parameters:
Verbosity: $(Verbosity)
CakeVersion: $(CakeVersion)
DotNetVersion: $(DotNetVersion)
NuGetVersion: $(NuGetVersion)
- powershell: .\build.ps1 -configuration Release -verbosity Verbose -target CI --publish-all --archive
displayName: "Build"
- template: ./.pipelines/artifacts.yml
parameters:
Artifacts: $(Artifacts)
- job: Windows
pool:
vmImage: "windows-2022"
dependsOn: GitVersion
steps:
- template: ./.pipelines/init.yml
parameters:
Verbosity: $(Verbosity)
CakeVersion: $(CakeVersion)
DotNetVersion: $(DotNetVersion)
NuGetVersion: $(NuGetVersion)
- powershell: .\build.ps1 -configuration Release -verbosity Verbose -target CI --publish-all --archive
displayName: "Build"
- template: ./.pipelines/artifacts.yml
parameters:
Artifacts: $(Artifacts)

- job: Release
pool:
vmImage: "ubuntu-latest"
dependsOn:
- macOS
- Linux
- Windows
steps:
- task: NuGetToolInstaller@1
displayName: "Install NuGet"
inputs:
versionSpec: $(NuGetVersion)
- task: DownloadBuildArtifacts@0
displayName: Download Packages
inputs:
downloadType: "single"
artifactName: "packages"
buildType: "current"
downloadPath: "$(System.ArtifactsDirectory)"
- task: DownloadBuildArtifacts@0
displayName: Download Deployment
inputs:
downloadType: "single"
artifactName: "deployment"
buildType: "current"
downloadPath: "$(System.ArtifactsDirectory)"
- task: DownloadBuildArtifacts@0
displayName: Download NuGet
inputs:
downloadType: "single"
artifactName: "nuget"
buildType: "current"
downloadPath: "$(System.ArtifactsDirectory)"
- task: NuGetCommand@2
displayName: "Push NuGet packages to Azure Artifacts"
inputs:
command: push
nuGetFeedType: internal
packagesToPush: "$(System.ArtifactsDirectory)/nuget/**/*.nupkg"
publishVstsFeed: Builds/omnisharp
allowPackageConflicts: true
condition: and(succeeded(), or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), eq(variables['Build.SourceBranch'], 'refs/heads/master')))
# Temporarily disable publishing to nuget.org while we attempt to renew authentication.
# - task: NuGetCommand@2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reenabled pushing to NuGet for official builds.

# displayName: "Push NuGet packages to nuget.org"
# inputs:
# command: push
# nuGetFeedType: external
# packagesToPush: "$(System.ArtifactsDirectory)/nuget/**/*.nupkg"
# publishFeedCredentials: nuget.org
# allowPackageConflicts: true
# condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
- script: |
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list
curl -L https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo apt-get install apt-transport-https
sudo apt-get update && sudo apt-get install azure-cli
az storage blob upload-batch --destination "releases" --source "$(System.ArtifactsDirectory)/deployment/" --overwrite --account-name roslynomnisharp --account-key $BLOB_KEY
displayName: Upload to Azure Storage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will no longer push artifacts to this storage account.

condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
env:
BLOB_KEY: $(BLOB_KEY)
- task: GitHubRelease@0
displayName: "GitHub release (edit)"
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
inputs:
gitHubConnection: github
repositoryName: OmniSharp/omnisharp-roslyn
action: edit
tag: "$(Build.SourceBranchName)"
title: "$(Build.SourceBranchName)"
assets: "$(System.ArtifactsDirectory)/packages/**/*"
assetUploadMode: replace
# releaseNotesSource: input
# releaseNotes: asdfasdf12
# isDraft: true
# isPreRelease: true
# addChangeLog: false
- job: Release
pool:
vmImage: "ubuntu-latest"
dependsOn:
- macOS
- Linux
- Windows
steps:
- template: ./.pipelines/init.yml
parameters:
Verbosity: $(Verbosity)
CakeVersion: $(CakeVersion)
DotNetVersion: $(DotNetVersion)
NuGetVersion: $(NuGetVersion)
- task: DownloadBuildArtifacts@0
displayName: Download Packages
inputs:
downloadType: "single"
artifactName: "packages"
buildType: "current"
downloadPath: "$(System.ArtifactsDirectory)"
- task: DownloadBuildArtifacts@0
displayName: Download Deployment
inputs:
downloadType: "single"
artifactName: "deployment"
buildType: "current"
downloadPath: "$(System.ArtifactsDirectory)"
- task: DownloadBuildArtifacts@0
displayName: Download NuGet
inputs:
downloadType: "single"
artifactName: "nuget"
buildType: "current"
downloadPath: "$(System.ArtifactsDirectory)"
- task: NuGetCommand@2
displayName: "Push NuGet packages to Azure Artifacts"
inputs:
command: push
nuGetFeedType: internal
packagesToPush: "$(System.ArtifactsDirectory)/nuget/**/*.nupkg"
publishVstsFeed: Builds/omnisharp
allowPackageConflicts: true
- task: NuGetCommand@2
displayName: "Push NuGet packages to nuget.org"
inputs:
command: push
nuGetFeedType: external
packagesToPush: "$(System.ArtifactsDirectory)/nuget/**/*.nupkg"
publishFeedCredentials: nuget.org
allowPackageConflicts: true
condition: and(succeeded(), eq(variables.IsOfficialRelease, true))
- task: GitHubRelease@1
displayName: "GitHub release (edit)"
inputs:
gitHubConnection: github
repositoryName: OmniSharp/omnisharp-roslyn
action: edit
tag: "$(Build.SourceBranchName)"
title: "$(Build.SourceBranchName)"
assets: "$(System.ArtifactsDirectory)/packages/**/*"
assetUploadMode: replace
# releaseNotesSource: input
# releaseNotes: asdfasdf12
# isDraft: true
isPreRelease: $(IsBetaRelease)
# addChangeLog: false
41 changes: 41 additions & 0 deletions doc/How-Releases-Are-Made.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# How O# Releases Are Made

The OmniSharp [release pipeline](https://dev.azure.com/omnisharp/Builds/_build?definitionId=2) runs from the OmniSharp Azure DevOps instance. It is defined in [azure-pipelines.yml](/azure-pipelines.yml).

## Rolling Beta Builds

Merges into the master branch generate an empty draft GitHub release with a beta version tag. The tag created for the release then causes a build that uploads the packages.

```mermaid
sequenceDiagram
autonumber
Maintainer ->> GitHub: Merges PR into the `master` branch
GitHub --) OmniSharp ADO: Merge to `master` triggers pipeline
activate OmniSharp ADO
OmniSharp ADO ->> GitHub: Pulls source for omnisharp-roslyn
note over OmniSharp ADO: Calculates a build version
OmniSharp ADO ->> GitHub: Creates a draft release and `v#35;.#35;.#35;-beta.#35;` tag
deactivate OmniSharp ADO
GitHub --) OmniSharp ADO: `v*` tag creation triggers pipeline
activate OmniSharp ADO
OmniSharp ADO ->> GitHub: Pulls source for omnisharp-roslyn
note over OmniSharp ADO: Builds packages for various platforms
OmniSharp ADO ->> GitHub: Adds packages to release and unmark as draft
deactivate OmniSharp ADO
```

## Official Builds

A maintainer creates an empty draft GitHub release with the appropriate version tag. The tag created for the release then causes a build that uploads the packages.

```mermaid
sequenceDiagram
autonumber
Maintainer ->> GitHub: Creates draft release with a`v#35;.#35;.#35;` tag
GitHub --) OmniSharp ADO: `v*` tag creation triggers pipeline
activate OmniSharp ADO
OmniSharp ADO ->> GitHub: Pulls source for omnisharp-roslyn
note over OmniSharp ADO: Builds packages for various platforms
OmniSharp ADO ->> GitHub: Adds packages to release and unmark as draft
deactivate OmniSharp ADO
```
Loading