Skip to content

Commit e643db6

Browse files
authored
Merge pull request actions#50 from actions/v-mazhuk/move-release-creation-to-github-actions
Move release and PR creation to GitHub Actions
2 parents 87b41b8 + 15099a8 commit e643db6

File tree

5 files changed

+113
-1
lines changed

5 files changed

+113
-1
lines changed

.github/workflows/create-pr.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Create Pull Request
2+
on:
3+
workflow_dispatch:
4+
5+
defaults:
6+
run:
7+
shell: pwsh
8+
9+
jobs:
10+
create_pr:
11+
name: Create Pull Request
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
submodules: true
17+
18+
- name: Create versions-manifest.json
19+
run: |
20+
./helpers/packages-generation/manifest-generator.ps1 -RepositoryFullName "$env:GITHUB_REPOSITORY" `
21+
-GitHubAccessToken "${{secrets.GITHUB_TOKEN}}" `
22+
-OutputFile "./versions-manifest.json" `
23+
-ConfigurationFile "./config/python-manifest-config.json"
24+
- name: Create GitHub PR
25+
run: |
26+
$formattedDate = Get-Date -Format "MM/dd/yyyy"
27+
./helpers/github/create-pull-request.ps1 `
28+
-RepositoryFullName "$env:GITHUB_REPOSITORY" `
29+
-AccessToken "${{secrets.GITHUB_TOKEN}}" `
30+
-BranchName "update-versions-manifest-file" `
31+
-CommitMessage "Update versions-manifest" `
32+
-PullRequestTitle "[versions-manifest] Update for release from ${formattedDate}" `
33+
-PullRequestBody "Update versions-manifest.json for release from ${formattedDate}"

.github/workflows/create-release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Create release
2+
on:
3+
repository_dispatch:
4+
types: [create-release]
5+
6+
jobs:
7+
create_release:
8+
name: Create release ${{ github.event.client_payload.ToolVersion }}
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Create release for Python ${{ github.event.client_payload.ToolVersion }}
12+
uses: actions/create-release@v1
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
with:
16+
tag_name: ${{ github.event.client_payload.TagName }}
17+
release_name: ${{ github.event.client_payload.ToolVersion }}
18+
body: ${{ github.event.client_payload.ReleaseBody }}

azure-pipelines/build-python-packages.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,17 @@ stages:
116116
Architecture: x86
117117
jobs:
118118
- template: /azure-pipelines/templates/test-job.yml
119+
120+
- stage: Publish_Release
121+
dependsOn: [Test_Python_MacOS, Test_Python_Ubuntu_1604, Test_Python_Ubuntu_1804, Test_Python_Ubuntu_2004, Test_Python_x64_Windows, Test_Python_x86_Windows]
122+
jobs:
123+
- deployment: Publish_Release
124+
pool:
125+
name: Azure Pipelines
126+
vmImage: ubuntu-18.04
127+
environment: 'Get Available Tools Versions - Publishing Approval'
128+
strategy:
129+
runOnce:
130+
deploy:
131+
steps:
132+
- template: /azure-pipelines/templates/publish-release-steps.yml
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
steps:
2+
- download: none
3+
4+
- checkout: self
5+
submodules: true
6+
7+
- task: DownloadPipelineArtifact@2
8+
inputs:
9+
source: 'current'
10+
path: $(Build.BinariesDirectory)
11+
12+
- task: PowerShell@2
13+
displayName: 'Create release Python $(VERSION)'
14+
inputs:
15+
TargetType: inline
16+
script: |
17+
$tagName = "$(VERSION)-$(Build.BuildId)"
18+
$releaseBody = "Python $(VERSION)"
19+
./helpers/github/create-release.ps1 -RepositoryFullName "$(Build.Repository.Name)" `
20+
-AccessToken "$(GITHUB_TOKEN)" `
21+
-ToolVersion "$(VERSION)" `
22+
-TagName "$tagName" `
23+
-ReleaseBody "$releaseBody" `
24+
-EventType "$(EVENT_TYPE)"
25+
- task: GitHubRelease@1
26+
displayName: 'Upload release assets'
27+
inputs:
28+
gitHubConnection: 'Github Connection'
29+
action: edit
30+
tag: '$(VERSION)-$(Build.BuildId)'
31+
title: '$(VERSION)'
32+
releaseNotesSource: inline
33+
releaseNotesInline: '$(RELEASE_NOTES_CONTENT)'
34+
assets: '$(Build.BinariesDirectory)/*/*'
35+
assetUploadMode: replace
36+
addChangeLog: false
37+
38+
- task: PowerShell@2
39+
displayName: 'Trigger "Create Pull Request" workflow'
40+
inputs:
41+
TargetType: inline
42+
script: |
43+
Import-Module (Join-Path (Get-Location).Path "github-api.psm1")
44+
$gitHubApi = Get-GitHubApi -RepositoryFullName "$(Build.Repository.Name)" -AccessToken "$(GITHUB_TOKEN)"
45+
$gitHubApi.CreateWorkflowDispatch("$(WORKFLOW_FILE_NAME)", "$(WORKFLOW_DISPATCH_REF)", "$(INPUTS)")
46+
Write-Host "Please find created Pull request here: $(Build.Repository.Uri)/pulls"
47+
workingDirectory: '$(Build.SourcesDirectory)/helpers/github'

0 commit comments

Comments
 (0)