[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:
|
types:
|
||||||
- created
|
- created
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
prepare-release-pr:
|
automation:
|
||||||
if: github.event_name == 'workflow_dispatch'
|
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:
|
steps:
|
||||||
- name: check out code
|
- name: check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||||
|
|
||||||
- name: Create GitHub Pull Request to prepare release
|
- name: Create GitHub Pull Request to prepare release
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
@ -43,25 +50,34 @@ jobs:
|
||||||
Import-Module .\build\scripts\prepare-release.psm1
|
Import-Module .\build\scripts\prepare-release.psm1
|
||||||
|
|
||||||
CreatePullRequestToUpdateChangelogsAndPublicApis `
|
CreatePullRequestToUpdateChangelogsAndPublicApis `
|
||||||
|
-gitRepository '${{ github.repository }}' `
|
||||||
-minVerTagPrefix '${{ inputs.tag-prefix }}' `
|
-minVerTagPrefix '${{ inputs.tag-prefix }}' `
|
||||||
-version '${{ inputs.version }}' `
|
-version '${{ inputs.version }}' `
|
||||||
-targetBranch '${{ github.ref_name }}'
|
-targetBranch '${{ github.ref_name }}' `
|
||||||
env:
|
-gitUserName '${{ needs.automation.outputs.username }}' `
|
||||||
GH_TOKEN: ${{ github.token }}
|
-gitUserEmail '${{ needs.automation.outputs.email }}'
|
||||||
|
|
||||||
lock-pr-and-post-notice-to-create-release-tag:
|
lock-pr-and-post-notice-to-create-release-tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
needs: automation
|
||||||
|
|
||||||
if: |
|
if: |
|
||||||
github.event_name == 'pull_request'
|
github.event_name == 'pull_request'
|
||||||
&& github.event.action == 'closed'
|
&& 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
|
&& github.event.pull_request.merged == true
|
||||||
&& startsWith(github.event.pull_request.title, '[repo] Prepare release ')
|
&& 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:
|
steps:
|
||||||
- name: check out code
|
- name: check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||||
|
|
||||||
- name: Lock GitHub Pull Request to prepare release
|
- name: Lock GitHub Pull Request to prepare release
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
@ -69,23 +85,27 @@ jobs:
|
||||||
Import-Module .\build\scripts\prepare-release.psm1
|
Import-Module .\build\scripts\prepare-release.psm1
|
||||||
|
|
||||||
LockPullRequestAndPostNoticeToCreateReleaseTag `
|
LockPullRequestAndPostNoticeToCreateReleaseTag `
|
||||||
-pullRequestNumber '${{ github.event.pull_request.number }}'
|
-gitRepository '${{ github.repository }}' `
|
||||||
env:
|
-pullRequestNumber '${{ github.event.pull_request.number }}' `
|
||||||
GH_TOKEN: ${{ github.token }}
|
-botUserName '${{ needs.automation.outputs.username }}'
|
||||||
|
|
||||||
create-release-tag-unlock-pr-post-notice:
|
create-release-tag-unlock-pr-post-notice:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
needs: automation
|
||||||
|
|
||||||
if: |
|
if: |
|
||||||
github.event_name == 'issue_comment'
|
github.event_name == 'issue_comment'
|
||||||
&& github.event.issue.pull_request
|
&& github.event.issue.pull_request
|
||||||
&& github.event.issue.locked == true
|
&& github.event.issue.locked == true
|
||||||
|
&& github.event.comment.user.login != needs.automation.outputs.username
|
||||||
&& contains(github.event.comment.body, '/CreateReleaseTag')
|
&& contains(github.event.comment.body, '/CreateReleaseTag')
|
||||||
&& startsWith(github.event.issue.title, '[repo] Prepare release ')
|
&& startsWith(github.event.issue.title, '[repo] Prepare release ')
|
||||||
&& github.event.issue.pull_request.merged_at
|
&& github.event.issue.pull_request.merged_at
|
||||||
|
&& needs.automation.outputs.enabled
|
||||||
|
|
||||||
runs-on: windows-latest
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||||
outputs:
|
|
||||||
tag: ${{ steps.create-tag.outputs.tag }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: check out code
|
- name: check out code
|
||||||
|
|
@ -93,6 +113,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
# Note: By default GitHub only fetches 1 commit which fails the git tag operation below
|
# Note: By default GitHub only fetches 1 commit which fails the git tag operation below
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets[needs.automation.outputs.token-secret-name] }}
|
||||||
|
|
||||||
- name: Create release tag
|
- name: Create release tag
|
||||||
id: create-tag
|
id: create-tag
|
||||||
|
|
@ -100,40 +121,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
Import-Module .\build\scripts\prepare-release.psm1
|
Import-Module .\build\scripts\prepare-release.psm1
|
||||||
|
|
||||||
$tag = ''
|
CreateReleaseTagAndPostNoticeOnPullRequest `
|
||||||
|
-gitRepository '${{ github.repository }}' `
|
||||||
CreateReleaseTag `
|
|
||||||
-pullRequestNumber '${{ github.event.issue.number }}' `
|
-pullRequestNumber '${{ github.event.issue.number }}' `
|
||||||
-actionRunId '${{ github.run_id }}' `
|
-botUserName '${{ needs.automation.outputs.username }}' `
|
||||||
-tag ([ref]$tag)
|
-gitUserName '${{ needs.automation.outputs.username }}' `
|
||||||
|
-gitUserEmail '${{ needs.automation.outputs.email }}'
|
||||||
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 }}
|
|
||||||
|
|
|
||||||
|
|
@ -13,29 +13,18 @@ on:
|
||||||
tags:
|
tags:
|
||||||
- 'core-*'
|
- 'core-*'
|
||||||
- 'coreunstable-*'
|
- '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:
|
schedule:
|
||||||
- cron: '0 0 * * *' # once in a day at 00:00
|
- cron: '0 0 * * *' # once in a day at 00:00
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
automation:
|
||||||
|
uses: ./.github/workflows/automation.yml
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
build-pack-publish:
|
build-pack-publish:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
artifact-id: ${{ steps.upload-artifacts.outputs.artifact-id }}
|
|
||||||
artifact-url: ${{ steps.upload-artifacts.outputs.artifact-url }}
|
artifact-url: ${{ steps.upload-artifacts.outputs.artifact-url }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -45,7 +34,6 @@ jobs:
|
||||||
# the version tag which is typically NOT on the first commit so we
|
# the version tag which is typically NOT on the first commit so we
|
||||||
# retrieve them all.
|
# retrieve them all.
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ inputs.tag || github.ref || 'main' }}
|
|
||||||
|
|
||||||
- name: Setup dotnet
|
- name: Setup dotnet
|
||||||
uses: actions/setup-dotnet@v4
|
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
|
run: dotnet build ./build/OpenTelemetry.proj --configuration Release --no-restore -p:Deterministic=true -p:BuildNumber=${{ github.run_number }} -p:RunningDotNetPack=true
|
||||||
|
|
||||||
- name: dotnet pack
|
- 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
|
- name: Publish Artifacts
|
||||||
id: upload-artifacts
|
id: upload-artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.tag || github.ref_name }}-packages
|
name: ${{ github.ref_name }}-packages
|
||||||
path: '**/bin/**/*.*nupkg'
|
path: '**/bin/**/*.*nupkg'
|
||||||
|
|
||||||
- name: Publish MyGet
|
- name: Publish MyGet
|
||||||
|
|
@ -74,26 +62,43 @@ jobs:
|
||||||
nuget setApiKey ${{ secrets.MYGET_TOKEN }} -Source https://www.myget.org/F/opentelemetry/api/v2/package
|
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
|
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
|
- name: Create GitHub Release draft
|
||||||
if: github.ref_type == 'tag' || inputs.tag
|
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
Import-Module .\build\scripts\post-release.psm1
|
Import-Module .\build\scripts\post-release.psm1
|
||||||
|
|
||||||
CreateDraftRelease `
|
CreateDraftRelease `
|
||||||
-tag '${{ inputs.tag || github.ref_name }}'
|
-gitRepository '${{ github.repository }}' `
|
||||||
env:
|
-tag '${{ github.ref_name }}'
|
||||||
GH_TOKEN: ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Create GitHub draft Pull Request to update stable build version in props
|
- name: Post notice when packages are ready
|
||||||
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'))
|
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
Import-Module .\build\scripts\post-release.psm1
|
Import-Module .\build\scripts\post-release.psm1
|
||||||
|
|
||||||
CreateStableVersionUpdatePullRequest `
|
TryPostPackagesReadyNoticeOnPrepareReleasePullRequest `
|
||||||
-tag '${{ inputs.tag || github.ref_name }}'
|
-gitRepository '${{ github.repository }}' `
|
||||||
env:
|
-tag '${{ github.ref_name }}' `
|
||||||
GH_TOKEN: ${{ github.token }}
|
-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}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{E69578EB-B456-4062-A645-877CD964528B}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.github\workflows\add-labels.yml = .github\workflows\add-labels.yml
|
.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\ci.yml = .github\workflows\ci.yml
|
||||||
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
|
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
|
||||||
.github\workflows\Component.BuildTest.yml = .github\workflows\Component.BuildTest.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\dotnet-format.yml = .github\workflows\dotnet-format.yml
|
||||||
.github\workflows\markdownlint.yml = .github\workflows\markdownlint.yml
|
.github\workflows\markdownlint.yml = .github\workflows\markdownlint.yml
|
||||||
.github\workflows\package-validation.yml = .github\workflows\package-validation.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\prepare-release.yml = .github\workflows\prepare-release.yml
|
||||||
.github\workflows\publish-packages-1.0.yml = .github\workflows\publish-packages-1.0.yml
|
.github\workflows\publish-packages-1.0.yml = .github\workflows\publish-packages-1.0.yml
|
||||||
.github\workflows\sanitycheck.yml = .github\workflows\sanitycheck.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 {
|
function CreateDraftRelease {
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||||
[Parameter(Mandatory=$true)][string]$tag
|
[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 = ''
|
$notes = ''
|
||||||
$firstPackageVersion = ''
|
|
||||||
|
|
||||||
foreach ($package in $packages)
|
foreach ($project in $projects)
|
||||||
{
|
{
|
||||||
$match = [regex]::Match($package, '(.*)\.(\d+\.\d+\.\d+.*?)\.nupkg')
|
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($project.Path)
|
||||||
$packageName = $match.Groups[1].Value
|
|
||||||
$packageVersion = $match.Groups[2].Value
|
|
||||||
|
|
||||||
if ($firstPackageVersion -eq '')
|
$changelogContent = Get-Content -Path "src/$projectName/CHANGELOG.md"
|
||||||
{
|
|
||||||
$firstPackageVersion = $packageVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
$changelogContent = Get-Content -Path "src/$packageName/CHANGELOG.md"
|
|
||||||
|
|
||||||
$started = $false
|
$started = $false
|
||||||
$content = ""
|
$content = ""
|
||||||
|
|
||||||
foreach ($line in $changelogContent)
|
foreach ($line in $changelogContent)
|
||||||
{
|
{
|
||||||
if ($line -like "## $packageVersion" -and $started -ne $true)
|
if ($line -like "## $version" -and $started -ne $true)
|
||||||
{
|
{
|
||||||
$started = $true
|
$started = $true
|
||||||
}
|
}
|
||||||
|
|
@ -63,16 +63,16 @@ function CreateDraftRelease {
|
||||||
|
|
||||||
$notes +=
|
$notes +=
|
||||||
@"
|
@"
|
||||||
* NuGet: [$packageName v$packageVersion](https://www.nuget.org/packages/$packageName/$packageVersion)
|
* NuGet: [$projectName v$version](https://www.nuget.org/packages/$projectName/$version)
|
||||||
|
|
||||||
$content
|
$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 `
|
gh release create $tag `
|
||||||
--title $tag `
|
--title $tag `
|
||||||
|
|
@ -94,12 +94,70 @@ $content
|
||||||
|
|
||||||
Export-ModuleMember -Function CreateDraftRelease
|
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 {
|
function CreateStableVersionUpdatePullRequest {
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||||
[Parameter(Mandatory=$true)][string]$tag,
|
[Parameter(Mandatory=$true)][string]$tag,
|
||||||
[Parameter()][string]$gitUserName=$gitHubBotUserName,
|
[Parameter()][string]$targetBranch="main",
|
||||||
[Parameter()][string]$gitUserEmail=$gitHubBotEmail,
|
[Parameter()][string]$gitUserName,
|
||||||
[Parameter()][string]$targetBranch="main"
|
[Parameter()][string]$gitUserEmail
|
||||||
)
|
)
|
||||||
|
|
||||||
$match = [regex]::Match($tag, '.*?-(.*)')
|
$match = [regex]::Match($tag, '.*?-(.*)')
|
||||||
|
|
@ -112,8 +170,14 @@ function CreateStableVersionUpdatePullRequest {
|
||||||
|
|
||||||
$branch="release/post-stable-${tag}-update"
|
$branch="release/post-stable-${tag}-update"
|
||||||
|
|
||||||
git config user.name $gitUserName
|
if ([string]::IsNullOrEmpty($gitUserName) -eq $false)
|
||||||
git config user.email $gitUserEmail
|
{
|
||||||
|
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
|
git switch --create $branch origin/$targetBranch --no-track 2>&1 | % ToString
|
||||||
if ($LASTEXITCODE -gt 0)
|
if ($LASTEXITCODE -gt 0)
|
||||||
|
|
@ -145,7 +209,7 @@ function CreateStableVersionUpdatePullRequest {
|
||||||
|
|
||||||
$body =
|
$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.
|
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 `
|
--body $body `
|
||||||
--base $targetBranch `
|
--base $targetBranch `
|
||||||
--head $branch `
|
--head $branch `
|
||||||
--label infra `
|
--label infra
|
||||||
--draft
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Export-ModuleMember -Function CreateStableVersionUpdatePullRequest
|
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 {
|
function CreatePullRequestToUpdateChangelogsAndPublicApis {
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||||
[Parameter(Mandatory=$true)][string]$minVerTagPrefix,
|
[Parameter(Mandatory=$true)][string]$minVerTagPrefix,
|
||||||
[Parameter(Mandatory=$true)][string]$version,
|
[Parameter(Mandatory=$true)][string]$version,
|
||||||
[Parameter()][string]$gitUserName=$gitHubBotUserName,
|
[Parameter()][string]$targetBranch="main",
|
||||||
[Parameter()][string]$gitUserEmail=$gitHubBotEmail,
|
[Parameter()][string]$gitUserName,
|
||||||
[Parameter()][string]$targetBranch="main"
|
[Parameter()][string]$gitUserEmail
|
||||||
)
|
)
|
||||||
|
|
||||||
$tag="${minVerTagPrefix}${version}"
|
$tag="${minVerTagPrefix}${version}"
|
||||||
$branch="release/prepare-${tag}-release"
|
$branch="release/prepare-${tag}-release"
|
||||||
|
|
||||||
git config user.name $gitUserName
|
if ([string]::IsNullOrEmpty($gitUserName) -eq $false)
|
||||||
git config user.email $gitUserEmail
|
{
|
||||||
|
git config user.name $gitUserName
|
||||||
|
}
|
||||||
|
if ([string]::IsNullOrEmpty($gitUserEmail) -eq $false)
|
||||||
|
{
|
||||||
|
git config user.email $gitUserEmail
|
||||||
|
}
|
||||||
|
|
||||||
git switch --create $branch 2>&1 | % ToString
|
git switch --create $branch 2>&1 | % ToString
|
||||||
if ($LASTEXITCODE -gt 0)
|
if ($LASTEXITCODE -gt 0)
|
||||||
|
|
@ -70,17 +70,14 @@ Export-ModuleMember -Function CreatePullRequestToUpdateChangelogsAndPublicApis
|
||||||
|
|
||||||
function LockPullRequestAndPostNoticeToCreateReleaseTag {
|
function LockPullRequestAndPostNoticeToCreateReleaseTag {
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||||
[Parameter(Mandatory=$true)][string]$pullRequestNumber,
|
[Parameter(Mandatory=$true)][string]$pullRequestNumber,
|
||||||
[Parameter()][string]$gitUserName=$gitHubBotUserName,
|
[Parameter(Mandatory=$true)][string]$botUserName
|
||||||
[Parameter()][string]$gitUserEmail=$gitHubBotEmail
|
|
||||||
)
|
)
|
||||||
|
|
||||||
git config user.name $gitUserName
|
|
||||||
git config user.email $gitUserEmail
|
|
||||||
|
|
||||||
$prViewResponse = gh pr view $pullRequestNumber --json mergeCommit,author,title | ConvertFrom-Json
|
$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'
|
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
|
Export-ModuleMember -Function LockPullRequestAndPostNoticeToCreateReleaseTag
|
||||||
|
|
||||||
function CreateReleaseTag {
|
function CreateReleaseTagAndPostNoticeOnPullRequest {
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory=$true)][string]$gitRepository,
|
||||||
[Parameter(Mandatory=$true)][string]$pullRequestNumber,
|
[Parameter(Mandatory=$true)][string]$pullRequestNumber,
|
||||||
[Parameter(Mandatory=$true)][string]$actionRunId,
|
[Parameter(Mandatory=$true)][string]$botUserName,
|
||||||
[Parameter()][string]$gitUserName=$gitHubBotUserName,
|
[Parameter()][string]$gitUserName,
|
||||||
[Parameter()][string]$gitUserEmail=$gitHubBotEmail,
|
[Parameter()][string]$gitUserEmail
|
||||||
[Parameter()][ref]$tag
|
|
||||||
)
|
)
|
||||||
|
|
||||||
git config user.name $gitUserName
|
|
||||||
git config user.email $gitUserEmail
|
|
||||||
|
|
||||||
$prViewResponse = gh pr view $pullRequestNumber --json mergeCommit,author,title | ConvertFrom-Json
|
$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'
|
throw 'PR author was unexpected'
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +132,7 @@ function CreateReleaseTag {
|
||||||
throw 'Could not parse tag from PR title'
|
throw 'Could not parse tag from PR title'
|
||||||
}
|
}
|
||||||
|
|
||||||
$tagValue = $match.Groups[1].Value
|
$tag = $match.Groups[1].Value
|
||||||
|
|
||||||
$commit = $prViewResponse.mergeCommit.oid
|
$commit = $prViewResponse.mergeCommit.oid
|
||||||
if ([string]::IsNullOrEmpty($commit) -eq $true)
|
if ([string]::IsNullOrEmpty($commit) -eq $true)
|
||||||
|
|
@ -146,13 +140,22 @@ function CreateReleaseTag {
|
||||||
throw 'Could not find merge commit'
|
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)
|
if ($LASTEXITCODE -gt 0)
|
||||||
{
|
{
|
||||||
throw 'git tag failure'
|
throw 'git tag failure'
|
||||||
}
|
}
|
||||||
|
|
||||||
git push origin $tagValue 2>&1 | % ToString
|
git push origin $tag 2>&1 | % ToString
|
||||||
if ($LASTEXITCODE -gt 0)
|
if ($LASTEXITCODE -gt 0)
|
||||||
{
|
{
|
||||||
throw 'git push failure'
|
throw 'git push failure'
|
||||||
|
|
@ -162,33 +165,12 @@ function CreateReleaseTag {
|
||||||
|
|
||||||
$body =
|
$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.
|
The [package workflow](https://github.com/$gitRepository/actions/workflows/publish-packages-1.0.yml) 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!
|
|
||||||
"@
|
"@
|
||||||
|
|
||||||
gh pr comment $pullRequestNumber --body $body
|
gh pr comment $pullRequestNumber --body $body
|
||||||
}
|
}
|
||||||
|
|
||||||
Export-ModuleMember -Function PostPackagesReadyNotice
|
Export-ModuleMember -Function CreateReleaseTagAndPostNoticeOnPullRequest
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue