From 63fbe5aac6fc7e169266a6e22934ce474c47c551 Mon Sep 17 00:00:00 2001 From: Lukas Pustina Date: Wed, 22 Apr 2020 11:18:57 +0200 Subject: [PATCH] Add GitHub Release to CI --- .ci/azure-pipelines.yml | 65 +++++++++++++--------------- .ci/templates/download_artifacts.yml | 21 +++++++++ 2 files changed, 50 insertions(+), 36 deletions(-) create mode 100644 .ci/templates/download_artifacts.yml diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index d47167d..49f3970 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -141,39 +141,32 @@ stages: artifact_names: - aws-watchtower - # - stage: Publish_Release - # displayName: "Publish Release" - # dependsOn: Build_Release_Artefacts - # condition: startsWith(variables['build.sourceBranch'], 'refs/tags/') - # jobs: - # - job: 'Publish_To_GitHub' - # displayName: "Publish to GitHub" - # steps: - # # Shortcut 'download' cannot be used as it does not restore into the original path; cf. https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/pipeline-artifacts?view=azure-devops&tabs=yaml#downloading-artifacts - # - task: DownloadPipelineArtifact@2 - # inputs: - # buildType: 'current' - # artifactName: 'Static_Linux_Binary' - # targetPath: '$(Build.ArtifactStagingDirectory)' - # displayName: "Download Static Linux Binary" - # - script: | - # ls -al $BUILD_ARTIFACTSTAGINGDIRECTORY && \ - # mv "$BUILD_ARTIFACTSTAGINGDIRECTORY/${CRATE_BIN_NAME}" "$BUILD_ARTIFACTSTAGINGDIRECTORY/${CRATE_BIN_NAME}-$AGENT_OSARCHITECTURE-musl-static" && \ - # ls -al $BUILD_ARTIFACTSTAGINGDIRECTORY - # displayName: "Prepare Assets for Upload" - # - task: GitHubRelease@0 - # displayName: "Create GitHub Release" - # inputs: - # gitHubConnection: 'lukaspustina-releaseupload' - # repositoryName: '$(Build.Repository.Name)' - # action: create - # target: '$(Build.SourceVersion)' - # tagSource: 'auto' - # tagPattern: 'v.*' - # tag: $(tagName) - # assets: $(Build.ArtifactStagingDirectory)/* - # assetUploadMode: 'delete' - # isDraft: false - # isPreRelease: false - # addChangeLog: true - # compareWith: 'lastFullRelease' + - stage: Publish_Release + displayName: "Publish Release" + dependsOn: Build_Release_Artefacts + condition: startsWith(variables['build.sourceBranch'], 'refs/tags/') + jobs: + - job: 'Publish_To_GitHub' + displayName: "Publish to GitHub" + steps: + - template: templates/download_artifacts.yml + parameters: + artifact_names: + - aws-watchtower + path: $(Build.ArtifactStagingDirectory) + - task: GitHubRelease@0 + displayName: "Create GitHub Release" + inputs: + gitHubConnection: 'lukaspustina-releaseupload' + repositoryName: '$(Build.Repository.Name)' + action: create + target: '$(Build.SourceVersion)' + tagSource: 'auto' + tagPattern: 'v.*' + tag: $(tagName) + assets: $(Build.ArtifactStagingDirectory)/* + assetUploadMode: 'delete' + isDraft: false + isPreRelease: false + addChangeLog: true + compareWith: 'lastFullRelease' diff --git a/.ci/templates/download_artifacts.yml b/.ci/templates/download_artifacts.yml new file mode 100644 index 0000000..3edf4e5 --- /dev/null +++ b/.ci/templates/download_artifacts.yml @@ -0,0 +1,21 @@ +--- + +parameters: + artifact_names: [] + path: $(Build.ArtifactStagingDirectory) + +steps: + - ${{ each artifact in parameters.artifact_names }}: + # Shortcut 'download' cannot be used as it does not restore into the original path; cf. https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/pipeline-artifacts?view=azure-devops&tabs=yaml#downloading-artifacts + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifactName: Static_Linux_Binary-${{ artifact }} + targetPath: ${{ parameters.path }} + displayName: Download Static Linux Binary ${{ artifact }} + - script: | + cd ${{ parameters.path }} + ls -al + mv -v "${{ artifact }}" "$${{ artifact }}-$AGENT_OSARCHITECTURE-musl-static" + ls -al + displayName: Prepare Assets for Upload ${{ artifact }}