From aa8ffd2e14545b319e8f8b722c994dce8a0c95d4 Mon Sep 17 00:00:00 2001 From: patr0nus Date: Wed, 4 Dec 2019 16:27:59 +0800 Subject: [PATCH] Add CD on a Linux agent. Fixes #33 --- azure-pipelines.yml | 46 +++++++++++++++++++++++++++++++-- node/scripts/publish-release.sh | 13 ++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 node/scripts/publish-release.sh diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 04f2e83..65148f4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -206,7 +206,7 @@ stages: - stage: Release dependsOn: BuildAndTest - condition: eq(variables['DESKGAP_AZ_RELEASE'], '1') + condition: contains(variables['Build.SourceVersionMessage'], '[ci release]') jobs: - job: Publish pool: @@ -216,4 +216,46 @@ stages: artifact: npmTarball - download: current artifact: distZips - - bash: ls "$(Pipeline.Workspace)" + + - bash: | + deskgapVersion=$(<$(Build.SourcesDirectory)/node/VERSION) + echo "##vso[task.setvariable variable=DESKGAP_VERSION]$deskgapVersion" + - task: GitHubRelease@0 + inputs: + gitHubConnection: 'GitHub connection 1' + action: 'create' + repositoryName: '$(Build.Repository.Name)' + target: '$(Build.SourceVersion)' + tagSource: 'manual' + tag: 'v$(DESKGAP_VERSION)' + assets: | + $(Pipeline.Workspace)/distZips/* + $(Pipeline.Workspace)/npmTarball/* + isDraft: false + addChangeLog: false + releaseNotesSource: 'file' + releaseNotesFile: $(Build.SourcesDirectory)/node/VERSION/WHATS_NEW.md + + - task: Bash@3 + displayName: "Publish to Binary and npm" + inputs: + filePath: $(Build.SourcesDirectory)/node/scripts/publish-release.sh + env: + DESKGAP_DISTS_DIR: $(Pipeline.Workspace)/distZips + DESKGAP_NPM_TARBALL: $(Pipeline.Workspace)/npmTarball/npm.tgz + DESKGAP_NPM_TEST_VERSION_FILE: $(Build.SourcesDirectory)/node/VERSION + + - bash: | + set -e + /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + sleep 6 + displayName: 'Start xvfb' + + - task: Bash@3 + displayName: "Final Test After Release" + inputs: + filePath: $(Build.SourcesDirectory)/node/scripts/test-npm.sh + env: + DISPLAY: ':99.0' + DESKGAP_NPM_TEST_INSTALL_WHAT: deskgap + DESKGAP_NPM_TEST_VERSION_FILE: $(Build.SourcesDirectory)/node/VERSION \ No newline at end of file diff --git a/node/scripts/publish-release.sh b/node/scripts/publish-release.sh new file mode 100644 index 0000000..68b852d --- /dev/null +++ b/node/scripts/publish-release.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -e +scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +deskgapVersion=$(<$scriptDir/../VERSION) + +for zipFilePath in $DESKGAP_DISTS_DIR/*.zip +do + zipFilename=$(basename $zipFilePath) + echo Uploading $zipFilename + curl -T "$zipFilePath" -u$DESKGAP_BINTRAY_USER:$DESKGAP_BINTRAY_KEY https://api.bintray.com/content/patr0nus/DeskGap/releases/$deskgapVersion/$zipFilename +done +curl -X POST -u$DESKGAP_BINTRAY_USER:$DESKGAP_BINTRAY_KEY https://api.bintray.com/content/patr0nus/DeskGap/releases/$deskgapVersion/publish +npm publish $DESKGAP_NPM_TARBALL