Skip to content
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
33 changes: 33 additions & 0 deletions eng/pipelines/templates/jobs/archetype-go-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
parameters:
DependsOn: Build
ServiceDirectory: ''

stages:
- ${{if and(eq(variables['Build.Reason'], 'Manual'), eq(variables['System.TeamProject'], 'internal'))}}:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this conditional is unnecessary since you're also including it in the template include for the archetype-sdk-client.yml file.

- stage: Release
displayName: 'Release: ${{parameters.ServiceDirectory}}'
dependsOn: ${{parameters.DependsOn}}
condition: and(succeeded(), ne(variables['SetDevVersion'], 'true'), ne(variables['Skip.Release'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-go-pr'))
jobs:
- deployment: TagRepository
displayName: "Create release tag"
condition: ne(variables['Skip.TagRepository'], 'true')
environment: github

pool:
name: azsdk-pool-mms-ubuntu-2004-general
vmImage: MMSUbuntu20.04

strategy:
runOnce:
deploy:
steps:
- checkout: self
- template: /eng/common/pipelines/templates/steps/retain-run.yml
- template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml
parameters:
ArtifactLocation: $(Build.SourcesDirectory)/sdk/${{parameters.ServiceDirectory}}
ReleaseSha: $(Build.SourceVersion)
RepoId: Azure/azure-sdk-for-go
WorkingDirectory: $(System.DefaultWorkingDirectory)

17 changes: 5 additions & 12 deletions eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,9 @@ stages:
Scope: $(SCOPE)
LintVersion: $(GoLintCLIVersion)

# Below stage won't work until the release stage is added/necessary.
# "Releasing" is just the package in the repository on github, but there may be some other metadata related
# tasks that become necessary later on.

# The Prerelease and Release stages are conditioned on whether we are building a pull request and the branch.
# - ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}:
# - template: archetype-go-release.yml
# parameters:
# DependsOn: Build
# ServiceDirectory: ${{parameters.ServiceDirectory}}
# Artifacts: ${{parameters.Artifacts}}
# ArtifactName: packages
# DocArtifact: documentation
- ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}:
- template: archetype-go-release.yml
parameters:
DependsOn: Build
ServiceDirectory: ${{parameters.ServiceDirectory}}
82 changes: 82 additions & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
$Language = "go"
$packagePattern = "go.mod"
# rewrite from ChangeLog-Operations.ps1 used in Get-ChangeLogEntriesFromContent for go uses vx.x.x as version number
$RELEASE_TITLE_REGEX = "(?<releaseNoteTitle>^\#+\s+(?<version>v$([AzureEngSemanticVersion]::SEMVER_REGEX))(\s+(?<releaseStatus>\(.+\))))"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@chidozieononiwu we consider adding an option "v?" to our core regex instead of duplicating this. We do similar support for python in our Regex already which supports different prerelease labels.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wonder whether there's already a definitely plan for this version compatibility change. Could we use the rewrite workaround before the eventually solution cause there are lots of release work for mgmt plane sdk refreshment recently.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There isn't a plan for this currently and I think what you have is an acceptable workaround for now.


# rewrite from artifact-metadata-parsing.ps1 used in RetrievePackages for fetch go single module info
function Get-go-PackageInfoFromPackageFile ($pkg, $workingDirectory)
Copy link
Copy Markdown
Member

@chidozieononiwu chidozieononiwu Aug 23, 2021

Choose a reason for hiding this comment

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

Looks like this method can also serve as Get-go-PackageInfoFromRepo, since go only pulls from the repo.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, Go release process has no package process and all package info can get directly from repo. But in order to reuse 'create-tag-and-git-release.ps1' script in eng sys which use Get-go-PackageInfoFromPackageFile to get release info, I create this function by tradeoff.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should definitely share and reuse this logic for both the packagefile and packageinfo.

@chidozieononiwu at some point I want to eliminate FromPackageFile function completely and either use PackageInfo or use the PackageInfo.json file we are generating as part of the build.

{
$workFolder = $pkg.Directory
$releaseNotes = ""

if ($workFolder -match "sdk[\/|\\]((?<repopath>(?<service>.*?)[\/|\\])?(?<arm>arm)?(?<pkgname>.*))")
{
if ($matches["arm"])
{
$packageName = "arm" + $matches["pkgname"]
$rpName = $matches["service"]
$pkgId = "sdk/$rpName/$packageName"
}
else
{
$packageName = $matches["pkgname"]
$pkgId = "sdk/$packageName"
}
}

$pkgVersion = Get-Version $workFolder

$changeLogLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
if ($changeLogLoc)
{
$releaseNotes = Get-ChangeLogEntryAsString -ChangeLogLocation $changeLogLoc -VersionString v$pkgVersion
}

$resultObj = New-Object PSObject -Property @{
PackageId = $pkgId
PackageVersion = $pkgVersion
ReleaseTag = "$pkgId/v$pkgVersion"
Deployable = $true
ReleaseNotes = $releaseNotes
}

return $resultObj
}

# get version from specific files (*constants.go, *version.go)
function Get-Version ($pkgPath)
{
# find any file with suffix
$versionFiles = @()
$version_file_suffixs = "*constants.go", "*version.go"
foreach ($versionFileSuffix in $version_file_suffixs)
{
Get-ChildItem -Recurse -Path $pkgPath -Filter $versionFileSuffix | ForEach-Object {
Write-Host "Adding $_ to list of version files"
$versionFiles += $_
}
}

# for each version file, use regex to search go version num
$go_version_regex = ".+\s*=\s*`".*v?(?<version>$([AzureEngSemanticVersion]::SEMVER_REGEX))`""
foreach ($versionFile in $versionFiles)
{
try
{
$content = Get-Content $versionFile -Raw
# finding where the version number are
if ($content -match $go_version_regex)
{
return $matches["version"]
}
}
catch
{
Write-Error "Error parsing version."
Write-Error $_
}
}

Write-Host "Cannot find release version."
exit 1
}