Merge pull request #50 from actions/v-mazhuk/move-release-creation-to-github-actions

Move release and PR creation to GitHub Actions
This commit is contained in:
MaksimZhukov 2020-08-28 18:01:59 +03:00 committed by GitHub
commit e643db6cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 113 additions and 1 deletions

33
.github/workflows/create-pr.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: Create Pull Request
on:
workflow_dispatch:
defaults:
run:
shell: pwsh
jobs:
create_pr:
name: Create Pull Request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Create versions-manifest.json
run: |
./helpers/packages-generation/manifest-generator.ps1 -RepositoryFullName "$env:GITHUB_REPOSITORY" `
-GitHubAccessToken "${{secrets.GITHUB_TOKEN}}" `
-OutputFile "./versions-manifest.json" `
-ConfigurationFile "./config/python-manifest-config.json"
- name: Create GitHub PR
run: |
$formattedDate = Get-Date -Format "MM/dd/yyyy"
./helpers/github/create-pull-request.ps1 `
-RepositoryFullName "$env:GITHUB_REPOSITORY" `
-AccessToken "${{secrets.GITHUB_TOKEN}}" `
-BranchName "update-versions-manifest-file" `
-CommitMessage "Update versions-manifest" `
-PullRequestTitle "[versions-manifest] Update for release from ${formattedDate}" `
-PullRequestBody "Update versions-manifest.json for release from ${formattedDate}"

18
.github/workflows/create-release.yml vendored Normal file
View File

@ -0,0 +1,18 @@
name: Create release
on:
repository_dispatch:
types: [create-release]
jobs:
create_release:
name: Create release ${{ github.event.client_payload.ToolVersion }}
runs-on: ubuntu-latest
steps:
- name: Create release for Python ${{ github.event.client_payload.ToolVersion }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.client_payload.TagName }}
release_name: ${{ github.event.client_payload.ToolVersion }}
body: ${{ github.event.client_payload.ReleaseBody }}

View File

@ -116,3 +116,17 @@ stages:
Architecture: x86
jobs:
- template: /azure-pipelines/templates/test-job.yml
- stage: Publish_Release
dependsOn: [Test_Python_MacOS, Test_Python_Ubuntu_1604, Test_Python_Ubuntu_1804, Test_Python_Ubuntu_2004, Test_Python_x64_Windows, Test_Python_x86_Windows]
jobs:
- deployment: Publish_Release
pool:
name: Azure Pipelines
vmImage: ubuntu-18.04
environment: 'Get Available Tools Versions - Publishing Approval'
strategy:
runOnce:
deploy:
steps:
- template: /azure-pipelines/templates/publish-release-steps.yml

View File

@ -0,0 +1,47 @@
steps:
- download: none
- checkout: self
submodules: true
- task: DownloadPipelineArtifact@2
inputs:
source: 'current'
path: $(Build.BinariesDirectory)
- task: PowerShell@2
displayName: 'Create release Python $(VERSION)'
inputs:
TargetType: inline
script: |
$tagName = "$(VERSION)-$(Build.BuildId)"
$releaseBody = "Python $(VERSION)"
./helpers/github/create-release.ps1 -RepositoryFullName "$(Build.Repository.Name)" `
-AccessToken "$(GITHUB_TOKEN)" `
-ToolVersion "$(VERSION)" `
-TagName "$tagName" `
-ReleaseBody "$releaseBody" `
-EventType "$(EVENT_TYPE)"
- task: GitHubRelease@1
displayName: 'Upload release assets'
inputs:
gitHubConnection: 'Github Connection'
action: edit
tag: '$(VERSION)-$(Build.BuildId)'
title: '$(VERSION)'
releaseNotesSource: inline
releaseNotesInline: '$(RELEASE_NOTES_CONTENT)'
assets: '$(Build.BinariesDirectory)/*/*'
assetUploadMode: replace
addChangeLog: false
- task: PowerShell@2
displayName: 'Trigger "Create Pull Request" workflow'
inputs:
TargetType: inline
script: |
Import-Module (Join-Path (Get-Location).Path "github-api.psm1")
$gitHubApi = Get-GitHubApi -RepositoryFullName "$(Build.Repository.Name)" -AccessToken "$(GITHUB_TOKEN)"
$gitHubApi.CreateWorkflowDispatch("$(WORKFLOW_FILE_NAME)", "$(WORKFLOW_DISPATCH_REF)", "$(INPUTS)")
Write-Host "Please find created Pull request here: $(Build.Repository.Uri)/pulls"
workingDirectory: '$(Build.SourcesDirectory)/helpers/github'

@ -1 +1 @@
Subproject commit 68072bedefb41436c6b70ddfa9adb8e631a3b6cf
Subproject commit f8f76caff1878d249468db3d55f045c0b707493b