[repo] Release automation improvements (#5657)
This commit is contained in:
parent
b9d56aa64e
commit
3ffa9160d9
|
|
@ -0,0 +1,34 @@
|
|||
name: Resolve automation settings
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
outputs:
|
||||
enabled:
|
||||
value: ${{ jobs.resolve-automation.outputs.enabled == 'true' }}
|
||||
token-secret-name:
|
||||
value: ${{ jobs.resolve-automation.outputs.token-secret-name }}
|
||||
username:
|
||||
value: ${{ vars.AUTOMATION_USERNAME }}
|
||||
email:
|
||||
value: ${{ vars.AUTOMATION_EMAIL }}
|
||||
secrets:
|
||||
OPENTELEMETRYBOT_GITHUB_TOKEN:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
resolve-automation:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
enabled: ${{ steps.evaluate.outputs.enabled }}
|
||||
token-secret-name: ${{ steps.evaluate.outputs.token-secret-name }}
|
||||
|
||||
env:
|
||||
OPENTELEMETRYBOT_GITHUB_TOKEN_EXISTS: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN != '' }}
|
||||
|
||||
steps:
|
||||
- id: evaluate
|
||||
run: |
|
||||
echo "enabled=${{ env.OPENTELEMETRYBOT_GITHUB_TOKEN_EXISTS == 'true' }}" >> "$GITHUB_OUTPUT"
|
||||
echo "token-secret-name=OPENTELEMETRYBOT_GITHUB_TOKEN" >> "$GITHUB_OUTPUT"
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
name: Complete release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
required: true
|
||||
description: 'Release tag'
|
||||
type: string
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
automation:
|
||||
uses: ./.github/workflows/automation.yml
|
||||
secrets: inherit
|
||||
|
||||
post-release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs:
|
||||
- automation
|
||||
|
||||
if: |
|
||||
needs.automation.outputs.enabled
|
||||
&&
|
||||
(
|
||||
(github.ref_type == 'tag' && startsWith(github.ref_name, 'core-') && !contains(github.ref_name, '-alpha') && !contains(github.ref_name, '-beta') && !contains(github.ref_name, '-rc'))
|
||||
|| (inputs.tag && startsWith(inputs.tag, 'core-') && !contains(inputs.tag, '-alpha') && !contains(inputs.tag, '-beta') && !contains(inputs.tag, '-rc'))
|
||||
)
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.repository.default_branch }}
|
||||
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
- name: Create GitHub Pull Request to update stable build version in props
|
||||
shell: pwsh
|
||||
run: |
|
||||
Import-Module .\build\scripts\post-release.psm1
|
||||
|
||||
CreateStableVersionUpdatePullRequest `
|
||||
-gitRepository '${{ github.repository }}' `
|
||||
-tag '${{ inputs.tag || github.ref_name }}' `
|
||||
-targetBranch '${{ github.event.repository.default_branch }}' `
|
||||
-gitUserName '${{ needs.automation.outputs.username }}' `
|
||||
-gitUserEmail '${{ needs.automation.outputs.email }}'
|
||||
|
|
@ -23,19 +23,26 @@ on:
|
|||
types:
|
||||
- created
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
prepare-release-pr:
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
automation:
|
||||
uses: ./.github/workflows/automation.yml
|
||||
secrets: inherit
|
||||
|
||||
runs-on: windows-latest
|
||||
prepare-release-pr:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: automation
|
||||
|
||||
if: github.event_name == 'workflow_dispatch' && needs.automation.outputs.enabled
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
steps:
|
||||
- name: check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
- name: Create GitHub Pull Request to prepare release
|
||||
shell: pwsh
|
||||
|
|
@ -43,25 +50,34 @@ jobs:
|
|||
Import-Module .\build\scripts\prepare-release.psm1
|
||||
|
||||
CreatePullRequestToUpdateChangelogsAndPublicApis `
|
||||
-gitRepository '${{ github.repository }}' `
|
||||
-minVerTagPrefix '${{ inputs.tag-prefix }}' `
|
||||
-version '${{ inputs.version }}' `
|
||||
-targetBranch '${{ github.ref_name }}'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
-targetBranch '${{ github.ref_name }}' `
|
||||
-gitUserName '${{ needs.automation.outputs.username }}' `
|
||||
-gitUserEmail '${{ needs.automation.outputs.email }}'
|
||||
|
||||
lock-pr-and-post-notice-to-create-release-tag:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: automation
|
||||
|
||||
if: |
|
||||
github.event_name == 'pull_request'
|
||||
&& github.event.action == 'closed'
|
||||
&& github.event.pull_request.user.login == 'github-actions[bot]'
|
||||
&& github.event.pull_request.user.login == needs.automation.outputs.username
|
||||
&& github.event.pull_request.merged == true
|
||||
&& startsWith(github.event.pull_request.title, '[repo] Prepare release ')
|
||||
&& needs.automation.outputs.enabled
|
||||
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
steps:
|
||||
- name: check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
- name: Lock GitHub Pull Request to prepare release
|
||||
shell: pwsh
|
||||
|
|
@ -69,23 +85,27 @@ jobs:
|
|||
Import-Module .\build\scripts\prepare-release.psm1
|
||||
|
||||
LockPullRequestAndPostNoticeToCreateReleaseTag `
|
||||
-pullRequestNumber '${{ github.event.pull_request.number }}'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
-gitRepository '${{ github.repository }}' `
|
||||
-pullRequestNumber '${{ github.event.pull_request.number }}' `
|
||||
-botUserName '${{ needs.automation.outputs.username }}'
|
||||
|
||||
create-release-tag-unlock-pr-post-notice:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: automation
|
||||
|
||||
if: |
|
||||
github.event_name == 'issue_comment'
|
||||
&& github.event.issue.pull_request
|
||||
&& github.event.issue.locked == true
|
||||
&& github.event.comment.user.login != needs.automation.outputs.username
|
||||
&& contains(github.event.comment.body, '/CreateReleaseTag')
|
||||
&& startsWith(github.event.issue.title, '[repo] Prepare release ')
|
||||
&& github.event.issue.pull_request.merged_at
|
||||
&& needs.automation.outputs.enabled
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
outputs:
|
||||
tag: ${{ steps.create-tag.outputs.tag }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
steps:
|
||||
- name: check out code
|
||||
|
|
@ -93,6 +113,7 @@ jobs:
|
|||
with:
|
||||
# Note: By default GitHub only fetches 1 commit which fails the git tag operation below
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
- name: Create release tag
|
||||
id: create-tag
|
||||
|
|
@ -100,40 +121,9 @@ jobs:
|
|||
run: |
|
||||
Import-Module .\build\scripts\prepare-release.psm1
|
||||
|
||||
$tag = ''
|
||||
|
||||
CreateReleaseTag `
|
||||
CreateReleaseTagAndPostNoticeOnPullRequest `
|
||||
-gitRepository '${{ github.repository }}' `
|
||||
-pullRequestNumber '${{ github.event.issue.number }}' `
|
||||
-actionRunId '${{ github.run_id }}' `
|
||||
-tag ([ref]$tag)
|
||||
|
||||
echo "tag=$tag" >> $env:GITHUB_OUTPUT
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
invoke-package-workflow:
|
||||
needs: create-release-tag-unlock-pr-post-notice
|
||||
uses: ./.github/workflows/publish-packages-1.0.yml
|
||||
with:
|
||||
tag: ${{ needs.create-release-tag-unlock-pr-post-notice.outputs.tag }}
|
||||
|
||||
post-packages-ready-notice:
|
||||
needs:
|
||||
- create-release-tag-unlock-pr-post-notice
|
||||
- invoke-package-workflow
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Post notice when packages are ready
|
||||
shell: pwsh
|
||||
run: |
|
||||
Import-Module .\build\scripts\prepare-release.psm1
|
||||
|
||||
PostPackagesReadyNotice `
|
||||
-pullRequestNumber '${{ github.event.issue.number }}' `
|
||||
-tag '${{ needs.create-release-tag-unlock-pr-post-notice.outputs.tag }}' `
|
||||
-packagesUrl '${{ needs.invoke-package-workflow.outputs.artifact-url }}'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
-botUserName '${{ needs.automation.outputs.username }}' `
|
||||
-gitUserName '${{ needs.automation.outputs.username }}' `
|
||||
-gitUserEmail '${{ needs.automation.outputs.email }}'
|
||||
|
|
|
|||
|
|
@ -13,29 +13,18 @@ on:
|
|||
tags:
|
||||
- 'core-*'
|
||||
- 'coreunstable-*'
|
||||
workflow_call:
|
||||
inputs:
|
||||
tag:
|
||||
required: true
|
||||
type: string
|
||||
outputs:
|
||||
artifact-id:
|
||||
value: ${{ jobs.build-pack-publish.outputs.artifact-id }}
|
||||
artifact-url:
|
||||
value: ${{ jobs.build-pack-publish.outputs.artifact-url }}
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # once in a day at 00:00
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
automation:
|
||||
uses: ./.github/workflows/automation.yml
|
||||
secrets: inherit
|
||||
|
||||
build-pack-publish:
|
||||
runs-on: windows-latest
|
||||
|
||||
outputs:
|
||||
artifact-id: ${{ steps.upload-artifacts.outputs.artifact-id }}
|
||||
artifact-url: ${{ steps.upload-artifacts.outputs.artifact-url }}
|
||||
|
||||
steps:
|
||||
|
|
@ -45,7 +34,6 @@ jobs:
|
|||
# the version tag which is typically NOT on the first commit so we
|
||||
# retrieve them all.
|
||||
fetch-depth: 0
|
||||
ref: ${{ inputs.tag || github.ref || 'main' }}
|
||||
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
|
|
@ -57,13 +45,13 @@ jobs:
|
|||
run: dotnet build ./build/OpenTelemetry.proj --configuration Release --no-restore -p:Deterministic=true -p:BuildNumber=${{ github.run_number }} -p:RunningDotNetPack=true
|
||||
|
||||
- name: dotnet pack
|
||||
run: dotnet pack ./build/OpenTelemetry.proj --configuration Release --no-restore --no-build -p:PackTag=${{ github.ref_type == 'tag' && github.ref_name || inputs.tag || '' }}
|
||||
run: dotnet pack ./build/OpenTelemetry.proj --configuration Release --no-restore --no-build -p:PackTag=${{ github.ref_type == 'tag' && github.ref_name || '' }}
|
||||
|
||||
- name: Publish Artifacts
|
||||
id: upload-artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ inputs.tag || github.ref_name }}-packages
|
||||
name: ${{ github.ref_name }}-packages
|
||||
path: '**/bin/**/*.*nupkg'
|
||||
|
||||
- name: Publish MyGet
|
||||
|
|
@ -74,26 +62,43 @@ jobs:
|
|||
nuget setApiKey ${{ secrets.MYGET_TOKEN }} -Source https://www.myget.org/F/opentelemetry/api/v2/package
|
||||
nuget push **/bin/**/*.nupkg -Source https://www.myget.org/F/opentelemetry/api/v2/package
|
||||
|
||||
post-build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs:
|
||||
- automation
|
||||
- build-pack-publish
|
||||
|
||||
if: needs.automation.outputs.enabled && github.event_name == 'push'
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
steps:
|
||||
- name: check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||
|
||||
- name: Create GitHub Release draft
|
||||
if: github.ref_type == 'tag' || inputs.tag
|
||||
shell: pwsh
|
||||
run: |
|
||||
Import-Module .\build\scripts\post-release.psm1
|
||||
|
||||
CreateDraftRelease `
|
||||
-tag '${{ inputs.tag || github.ref_name }}'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
-gitRepository '${{ github.repository }}' `
|
||||
-tag '${{ github.ref_name }}'
|
||||
|
||||
- name: Create GitHub draft Pull Request to update stable build version in props
|
||||
if: |
|
||||
(github.ref_type == 'tag' && startsWith(github.ref_name, 'core-') && !contains(github.ref_name, '-alpha') && !contains(github.ref_name, '-beta') && !contains(github.ref_name, '-rc'))
|
||||
|| (inputs.tag && startsWith(inputs.tag, 'core-') && !contains(inputs.tag, '-alpha') && !contains(inputs.tag, '-beta') && !contains(inputs.tag, '-rc'))
|
||||
- name: Post notice when packages are ready
|
||||
shell: pwsh
|
||||
run: |
|
||||
Import-Module .\build\scripts\post-release.psm1
|
||||
|
||||
CreateStableVersionUpdatePullRequest `
|
||||
-tag '${{ inputs.tag || github.ref_name }}'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TryPostPackagesReadyNoticeOnPrepareReleasePullRequest `
|
||||
-gitRepository '${{ github.repository }}' `
|
||||
-tag '${{ github.ref_name }}' `
|
||||
-tagSha '${{ github.sha }}' `
|
||||
-packagesUrl '${{ needs.build-pack-publish.outputs.artifact-url }}' `
|
||||
-botUserName '${{ needs.automation.outputs.username }}'
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{E69578EB-B456-4062-A645-877CD964528B}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.github\workflows\add-labels.yml = .github\workflows\add-labels.yml
|
||||
.github\workflows\automation.yml = .github\workflows\automation.yml
|
||||
.github\workflows\ci.yml = .github\workflows\ci.yml
|
||||
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
|
||||
.github\workflows\Component.BuildTest.yml = .github\workflows\Component.BuildTest.yml
|
||||
|
|
@ -94,6 +95,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
|
|||
.github\workflows\dotnet-format.yml = .github\workflows\dotnet-format.yml
|
||||
.github\workflows\markdownlint.yml = .github\workflows\markdownlint.yml
|
||||
.github\workflows\package-validation.yml = .github\workflows\package-validation.yml
|
||||
.github\workflows\post-release.yml = .github\workflows\post-release.yml
|
||||
.github\workflows\prepare-release.yml = .github\workflows\prepare-release.yml
|
||||
.github\workflows\publish-packages-1.0.yml = .github\workflows\publish-packages-1.0.yml
|
||||
.github\workflows\sanitycheck.yml = .github\workflows\sanitycheck.yml
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
$gitHubBotUserName="github-actions[bot]"
|
||||
$gitHubBotEmail="41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
$repoViewResponse = gh repo view --json nameWithOwner | ConvertFrom-Json
|
||||
|
||||
$gitRepository = $repoViewResponse.nameWithOwner
|
||||
|
||||
function CreateDraftRelease {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||
[Parameter(Mandatory=$true)][string]$tag
|
||||
)
|
||||
|
||||
$packages = (Get-ChildItem -Path src/*/bin/Release/*.nupkg).Name
|
||||
$match = [regex]::Match($tag, '^(.*?-)(.*)$')
|
||||
if ($match.Success -eq $false)
|
||||
{
|
||||
throw 'Could not parse prefix or version from tag'
|
||||
}
|
||||
|
||||
$tagPrefix = $match.Groups[1].Value
|
||||
$version = $match.Groups[2].Value
|
||||
|
||||
$projects = @(Get-ChildItem -Path src/**/*.csproj | Select-String "<MinVerTagPrefix>$tagPrefix</MinVerTagPrefix>" -List | Select Path)
|
||||
|
||||
if ($projects.Length -eq 0)
|
||||
{
|
||||
throw 'No projects found with MinVerTagPrefix matching prefix from tag'
|
||||
}
|
||||
|
||||
$notes = ''
|
||||
$firstPackageVersion = ''
|
||||
|
||||
foreach ($package in $packages)
|
||||
foreach ($project in $projects)
|
||||
{
|
||||
$match = [regex]::Match($package, '(.*)\.(\d+\.\d+\.\d+.*?)\.nupkg')
|
||||
$packageName = $match.Groups[1].Value
|
||||
$packageVersion = $match.Groups[2].Value
|
||||
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($project.Path)
|
||||
|
||||
if ($firstPackageVersion -eq '')
|
||||
{
|
||||
$firstPackageVersion = $packageVersion
|
||||
}
|
||||
|
||||
$changelogContent = Get-Content -Path "src/$packageName/CHANGELOG.md"
|
||||
$changelogContent = Get-Content -Path "src/$projectName/CHANGELOG.md"
|
||||
|
||||
$started = $false
|
||||
$content = ""
|
||||
|
||||
foreach ($line in $changelogContent)
|
||||
{
|
||||
if ($line -like "## $packageVersion" -and $started -ne $true)
|
||||
if ($line -like "## $version" -and $started -ne $true)
|
||||
{
|
||||
$started = $true
|
||||
}
|
||||
|
|
@ -63,16 +63,16 @@ function CreateDraftRelease {
|
|||
|
||||
$notes +=
|
||||
@"
|
||||
* NuGet: [$packageName v$packageVersion](https://www.nuget.org/packages/$packageName/$packageVersion)
|
||||
* NuGet: [$projectName v$version](https://www.nuget.org/packages/$projectName/$version)
|
||||
|
||||
$content
|
||||
|
||||
See [CHANGELOG](https://github.com/$gitRepository/blob/$tag/src/$packageName/CHANGELOG.md) for details.
|
||||
See [CHANGELOG](https://github.com/$gitRepository/blob/$tag/src/$projectName/CHANGELOG.md) for details.
|
||||
|
||||
"@
|
||||
}
|
||||
|
||||
if ($firstPackageVersion -match '-alpha' -or $firstPackageVersion -match '-beta' -or $firstPackageVersion -match '-rc')
|
||||
if ($version -match '-alpha' -or $version -match '-beta' -or $version -match '-rc')
|
||||
{
|
||||
gh release create $tag `
|
||||
--title $tag `
|
||||
|
|
@ -94,12 +94,70 @@ $content
|
|||
|
||||
Export-ModuleMember -Function CreateDraftRelease
|
||||
|
||||
function TryPostPackagesReadyNoticeOnPrepareReleasePullRequest {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||
[Parameter(Mandatory=$true)][string]$tag,
|
||||
[Parameter(Mandatory=$true)][string]$tagSha,
|
||||
[Parameter(Mandatory=$true)][string]$packagesUrl,
|
||||
[Parameter(Mandatory=$true)][string]$botUserName
|
||||
)
|
||||
|
||||
$prListResponse = gh pr list --search $tagSha --state merged --json number,author,title,comments | ConvertFrom-Json
|
||||
|
||||
if ($prListResponse.Length -eq 0)
|
||||
{
|
||||
Write-Host 'No prepare release PR found for tag & commit skipping post notice'
|
||||
return
|
||||
}
|
||||
|
||||
foreach ($pr in $prListResponse)
|
||||
{
|
||||
if ($pr.author.login -ne $botUserName -or $pr.title -ne "[repo] Prepare release $tag")
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
$foundComment = $false
|
||||
foreach ($comment in $pr.comments)
|
||||
{
|
||||
if ($comment.author.login -eq $botUserName -and $comment.body.StartsWith("I just pushed the [$tag]"))
|
||||
{
|
||||
$foundComment = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ($foundComment -eq $false)
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
$body =
|
||||
@"
|
||||
The packages for [$tag](https://github.com/$gitRepository/releases/tag/$tag) are now available: $packagesUrl.
|
||||
|
||||
Have a nice day!
|
||||
"@
|
||||
|
||||
$pullRequestNumber = $pr.number
|
||||
|
||||
gh pr comment $pullRequestNumber --body $body
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host 'No prepare release PR found matched author and title with a valid comment'
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function TryPostPackagesReadyNoticeOnPrepareReleasePullRequest
|
||||
|
||||
function CreateStableVersionUpdatePullRequest {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||
[Parameter(Mandatory=$true)][string]$tag,
|
||||
[Parameter()][string]$gitUserName=$gitHubBotUserName,
|
||||
[Parameter()][string]$gitUserEmail=$gitHubBotEmail,
|
||||
[Parameter()][string]$targetBranch="main"
|
||||
[Parameter()][string]$targetBranch="main",
|
||||
[Parameter()][string]$gitUserName,
|
||||
[Parameter()][string]$gitUserEmail
|
||||
)
|
||||
|
||||
$match = [regex]::Match($tag, '.*?-(.*)')
|
||||
|
|
@ -112,8 +170,14 @@ function CreateStableVersionUpdatePullRequest {
|
|||
|
||||
$branch="release/post-stable-${tag}-update"
|
||||
|
||||
git config user.name $gitUserName
|
||||
git config user.email $gitUserEmail
|
||||
if ([string]::IsNullOrEmpty($gitUserName) -eq $false)
|
||||
{
|
||||
git config user.name $gitUserName
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($gitUserEmail) -eq $false)
|
||||
{
|
||||
git config user.email $gitUserEmail
|
||||
}
|
||||
|
||||
git switch --create $branch origin/$targetBranch --no-track 2>&1 | % ToString
|
||||
if ($LASTEXITCODE -gt 0)
|
||||
|
|
@ -145,7 +209,7 @@ function CreateStableVersionUpdatePullRequest {
|
|||
|
||||
$body =
|
||||
@"
|
||||
Note: This PR was opened automatically by the [package workflow](https://github.com/$gitRepository/actions/workflows/publish-packages-1.0.yml).
|
||||
Note: This PR was opened automatically by the [post-release workflow](https://github.com/$gitRepository/actions/workflows/post-release.yml).
|
||||
|
||||
Merge once packages are available on NuGet and the build passes.
|
||||
|
||||
|
|
@ -159,8 +223,7 @@ Merge once packages are available on NuGet and the build passes.
|
|||
--body $body `
|
||||
--base $targetBranch `
|
||||
--head $branch `
|
||||
--label infra `
|
||||
--draft
|
||||
--label infra
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function CreateStableVersionUpdatePullRequest
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
$gitHubBotUserName="github-actions[bot]"
|
||||
$gitHubBotEmail="41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
$repoViewResponse = gh repo view --json nameWithOwner | ConvertFrom-Json
|
||||
|
||||
$gitRepository = $repoViewResponse.nameWithOwner
|
||||
|
||||
function CreatePullRequestToUpdateChangelogsAndPublicApis {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||
[Parameter(Mandatory=$true)][string]$minVerTagPrefix,
|
||||
[Parameter(Mandatory=$true)][string]$version,
|
||||
[Parameter()][string]$gitUserName=$gitHubBotUserName,
|
||||
[Parameter()][string]$gitUserEmail=$gitHubBotEmail,
|
||||
[Parameter()][string]$targetBranch="main"
|
||||
[Parameter()][string]$targetBranch="main",
|
||||
[Parameter()][string]$gitUserName,
|
||||
[Parameter()][string]$gitUserEmail
|
||||
)
|
||||
|
||||
$tag="${minVerTagPrefix}${version}"
|
||||
$branch="release/prepare-${tag}-release"
|
||||
|
||||
git config user.name $gitUserName
|
||||
git config user.email $gitUserEmail
|
||||
if ([string]::IsNullOrEmpty($gitUserName) -eq $false)
|
||||
{
|
||||
git config user.name $gitUserName
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($gitUserEmail) -eq $false)
|
||||
{
|
||||
git config user.email $gitUserEmail
|
||||
}
|
||||
|
||||
git switch --create $branch 2>&1 | % ToString
|
||||
if ($LASTEXITCODE -gt 0)
|
||||
|
|
@ -70,17 +70,14 @@ Export-ModuleMember -Function CreatePullRequestToUpdateChangelogsAndPublicApis
|
|||
|
||||
function LockPullRequestAndPostNoticeToCreateReleaseTag {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||
[Parameter(Mandatory=$true)][string]$pullRequestNumber,
|
||||
[Parameter()][string]$gitUserName=$gitHubBotUserName,
|
||||
[Parameter()][string]$gitUserEmail=$gitHubBotEmail
|
||||
[Parameter(Mandatory=$true)][string]$botUserName
|
||||
)
|
||||
|
||||
git config user.name $gitUserName
|
||||
git config user.email $gitUserEmail
|
||||
|
||||
$prViewResponse = gh pr view $pullRequestNumber --json mergeCommit,author,title | ConvertFrom-Json
|
||||
|
||||
if ($prViewResponse.author.is_bot -eq $false -or $prViewResponse.author.login -ne 'app/github-actions')
|
||||
if ($prViewResponse.author.login -ne $botUserName)
|
||||
{
|
||||
throw 'PR author was unexpected'
|
||||
}
|
||||
|
|
@ -113,21 +110,18 @@ Post a comment with "/CreateReleaseTag" in the body if you would like me to crea
|
|||
|
||||
Export-ModuleMember -Function LockPullRequestAndPostNoticeToCreateReleaseTag
|
||||
|
||||
function CreateReleaseTag {
|
||||
function CreateReleaseTagAndPostNoticeOnPullRequest {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||
[Parameter(Mandatory=$true)][string]$pullRequestNumber,
|
||||
[Parameter(Mandatory=$true)][string]$actionRunId,
|
||||
[Parameter()][string]$gitUserName=$gitHubBotUserName,
|
||||
[Parameter()][string]$gitUserEmail=$gitHubBotEmail,
|
||||
[Parameter()][ref]$tag
|
||||
[Parameter(Mandatory=$true)][string]$botUserName,
|
||||
[Parameter()][string]$gitUserName,
|
||||
[Parameter()][string]$gitUserEmail
|
||||
)
|
||||
|
||||
git config user.name $gitUserName
|
||||
git config user.email $gitUserEmail
|
||||
|
||||
$prViewResponse = gh pr view $pullRequestNumber --json mergeCommit,author,title | ConvertFrom-Json
|
||||
|
||||
if ($prViewResponse.author.is_bot -eq $false -or $prViewResponse.author.login -ne 'app/github-actions')
|
||||
if ($prViewResponse.author.login -ne $botUserName)
|
||||
{
|
||||
throw 'PR author was unexpected'
|
||||
}
|
||||
|
|
@ -138,7 +132,7 @@ function CreateReleaseTag {
|
|||
throw 'Could not parse tag from PR title'
|
||||
}
|
||||
|
||||
$tagValue = $match.Groups[1].Value
|
||||
$tag = $match.Groups[1].Value
|
||||
|
||||
$commit = $prViewResponse.mergeCommit.oid
|
||||
if ([string]::IsNullOrEmpty($commit) -eq $true)
|
||||
|
|
@ -146,13 +140,22 @@ function CreateReleaseTag {
|
|||
throw 'Could not find merge commit'
|
||||
}
|
||||
|
||||
git tag -a $tagValue -m "$tagValue" $commit 2>&1 | % ToString
|
||||
if ([string]::IsNullOrEmpty($gitUserName) -eq $false)
|
||||
{
|
||||
git config user.name $gitUserName
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($gitUserEmail) -eq $false)
|
||||
{
|
||||
git config user.email $gitUserEmail
|
||||
}
|
||||
|
||||
git tag -a $tag -m "$tag" $commit 2>&1 | % ToString
|
||||
if ($LASTEXITCODE -gt 0)
|
||||
{
|
||||
throw 'git tag failure'
|
||||
}
|
||||
|
||||
git push origin $tagValue 2>&1 | % ToString
|
||||
git push origin $tag 2>&1 | % ToString
|
||||
if ($LASTEXITCODE -gt 0)
|
||||
{
|
||||
throw 'git push failure'
|
||||
|
|
@ -162,33 +165,12 @@ function CreateReleaseTag {
|
|||
|
||||
$body =
|
||||
@"
|
||||
I just pushed the [$tagValue](https://github.com/$gitRepository/releases/tag/$tagValue) tag.
|
||||
I just pushed the [$tag](https://github.com/$gitRepository/releases/tag/$tag) tag.
|
||||
|
||||
The [package workflow](https://github.com/$gitRepository/actions/runs/$actionRunId) should begin momentarily.
|
||||
"@
|
||||
|
||||
gh pr comment $pullRequestNumber --body $body
|
||||
|
||||
$tag.value = $tagValue
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function CreateReleaseTag
|
||||
|
||||
function PostPackagesReadyNotice {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$pullRequestNumber,
|
||||
[Parameter(Mandatory=$true)][string]$tag,
|
||||
[Parameter(Mandatory=$true)][string]$packagesUrl
|
||||
)
|
||||
|
||||
$body =
|
||||
@"
|
||||
The packages for [$tag](https://github.com/$gitRepository/releases/tag/$tag) are now available: $packagesUrl.
|
||||
|
||||
Have a nice day!
|
||||
The [package workflow](https://github.com/$gitRepository/actions/workflows/publish-packages-1.0.yml) should begin momentarily.
|
||||
"@
|
||||
|
||||
gh pr comment $pullRequestNumber --body $body
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function PostPackagesReadyNotice
|
||||
Export-ModuleMember -Function CreateReleaseTagAndPostNoticeOnPullRequest
|
||||
|
|
|
|||
Loading…
Reference in New Issue