diff --git a/script/publish-release b/script/publish-release index 47ef55a9b..3d5eaa5c6 100644 --- a/script/publish-release +++ b/script/publish-release @@ -13,40 +13,47 @@ const argv = yargs .usage('Usage: $0 [options]') .help('help') .describe('assets-path', 'Path to the folder where all release assets are stored') + .describe('s3-path', 'Indicates the S3 path in which the assets should be uploaded') + .describe('create-github-release', 'Creates a GitHub release for this build, draft if release branch or public if Nightly') .wrap(yargs.terminalWidth()) .argv -let assetsPath = argv.assetsPath || path.join(CONFIG.repositoryRootPath, 'out') -let assets = glob.sync(path.join(assetsPath, '*(*.exe|*.zip|*.nupkg|*.tar.gz|*.rpm|*.deb|RELEASES*)')) +const assetsPath = argv.assetsPath || path.join(CONFIG.repositoryRootPath, 'out') +const assets = glob.sync(path.join(assetsPath, '*(*.exe|*.zip|*.nupkg|*.tar.gz|*.rpm|*.deb|RELEASES*)')) +const bucketPath = argv.s3Path || `releases/v${CONFIG.computedAppVersion}/` -console.log(`Uploading release assets for ${CONFIG.computedAppVersion} to S3`) +console.log(`Uploading release assets for ${CONFIG.computedAppVersion} to S3 under '${bucketPath}'`) uploadToS3( process.env.ATOM_RELEASES_S3_KEY, process.env.ATOM_RELEASES_S3_SECRET, process.env.ATOM_RELEASES_S3_BUCKET, - `releases/v${CONFIG.computedAppVersion}/`, + bucketPath, assets).then( () => { - console.log(`Publishing GitHub release ${CONFIG.computedAppVersion}`) - publishRelease({ - token: process.env.GITHUB_TOKEN, - owner: 'atom', - repo: CONFIG.channel !== 'nightly' ? 'atom' : 'atom-nightly-releases', - name: CONFIG.computedAppVersion, - tag: `v${CONFIG.computedAppVersion}`, - draft: false, - prerelease: CONFIG.channel !== 'stable', - reuseRelease: true, - skipIfPublished: true, - assets - }, function (err, release) { - if (err) { - console.error("An error occurred while publishing the release:\n\n", err) - } else { - console.log("Release published successfully: ", release.html_url) - } - }) + if (argv.createGithubRelease) { + console.log(`Creating GitHub release v${CONFIG.computedAppVersion}`) + publishRelease({ + token: process.env.GITHUB_TOKEN, + owner: 'atom', + repo: CONFIG.channel !== 'nightly' ? 'atom' : 'atom-nightly-releases', + name: CONFIG.computedAppVersion, + tag: `v${CONFIG.computedAppVersion}`, + draft: false, + prerelease: CONFIG.channel !== 'stable', + reuseRelease: true, + skipIfPublished: true, + assets + }, function (err, release) { + if (err) { + console.error("An error occurred while publishing the release:\n\n", err) + } else { + console.log("Release published successfully: ", release.html_url) + } + }) + } else { + console.log("Skipping GitHub release creation") + } }).catch((err) => { console.error('An error occurred while uploading the release:', err) }) diff --git a/script/vsts/get-release-version.js b/script/vsts/get-release-version.js index ff51a6cfb..b25f06687 100644 --- a/script/vsts/get-release-version.js +++ b/script/vsts/get-release-version.js @@ -40,6 +40,15 @@ async function getReleaseVersion () { // the associated variables. console.log(`##vso[task.setvariable variable=ReleaseVersion;isOutput=true]${releaseVersion}`) console.log(`##vso[build.updatebuildnumber]${releaseVersion}+${process.env.BUILD_BUILDNUMBER}`) + + // Write out some variables that indicate whether artifacts should be uploaded + const buildBranch = process.env.BUILD_SOURCEBRANCHNAME + const isReleaseBranch = buildBranch.match(/\d\.\d+-releases/) !== null + const isSignedZipBranch = + buildBranch.startsWith('electron-') || + buildBranch === 'master' && !process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER + console.log(`##vso[task.setvariable variable=IsReleaseBranch;isOutput=true]${isReleaseBranch}`) + console.log(`##vso[task.setvariable variable=IsSignedZipBranch;isOutput=true]${isSignedZipBranch}`) } getReleaseVersion() diff --git a/script/vsts/nightly-release.yml b/script/vsts/nightly-release.yml index 33da441fb..81d64876c 100644 --- a/script/vsts/nightly-release.yml +++ b/script/vsts/nightly-release.yml @@ -47,7 +47,7 @@ phases: artifactName: Binaries - script: | - $(Build.SourcesDirectory)\script\publish-release.cmd --assets-path "$(System.ArtifactsDirectory)/Binaries" + $(Build.SourcesDirectory)\script\publish-release.cmd --create-github-release --assets-path "$(System.ArtifactsDirectory)/Binaries" env: GITHUB_TOKEN: $(GITHUB_TOKEN) ATOM_RELEASE_VERSION: $(ReleaseVersion) diff --git a/script/vsts/platforms/linux.yml b/script/vsts/platforms/linux.yml index 6e569cc5e..675de8063 100644 --- a/script/vsts/platforms/linux.yml +++ b/script/vsts/platforms/linux.yml @@ -36,6 +36,7 @@ phases: CI: true CI_PROVIDER: VSTS displayName: Run tests + condition: and(succeeded(), ne(variables['Atom.SkipTests'], 'true')) - task: PublishBuildArtifacts@1 inputs: diff --git a/script/vsts/platforms/macos.yml b/script/vsts/platforms/macos.yml index c3f0c39cf..9462d69f1 100644 --- a/script/vsts/platforms/macos.yml +++ b/script/vsts/platforms/macos.yml @@ -3,6 +3,8 @@ phases: dependsOn: GetReleaseVersion variables: ReleaseVersion: $[ dependencies.GetReleaseVersion.outputs['Version.ReleaseVersion'] ] + IsReleaseBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsReleaseBranch'] ] + IsSignedZipBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsSignedZipBranch'] ] queue: name: Hosted macOS Preview timeoutInMinutes: 180 @@ -14,9 +16,15 @@ phases: displayName: Install Node.js 8.9.3 - script: | - script/build --code-sign --compress-artifacts + if [ $IS_RELEASE_BRANCH == "true" ] || [ $IS_SIGNED_ZIP_BRANCH == "true" ]; then + script/build --code-sign --compress-artifacts + else + script/build --compress-artifacts + fi displayName: Build Atom env: + IS_RELEASE_BRANCH: $(IsReleaseBranch) + IS_SIGNED_ZIP_BRANCH: $(IsSignedZipBranch) ATOM_RELEASE_VERSION: $(ReleaseVersion) ATOM_MAC_CODE_SIGNING_CERT_DOWNLOAD_URL: $(ATOM_MAC_CODE_SIGNING_CERT_DOWNLOAD_URL) ATOM_MAC_CODE_SIGNING_CERT_PASSWORD: $(ATOM_MAC_CODE_SIGNING_CERT_PASSWORD) @@ -33,6 +41,7 @@ phases: CI: true CI_PROVIDER: VSTS displayName: Run tests + condition: and(succeeded(), ne(variables['Atom.SkipTests'], 'true')) - script: | cp $(Build.SourcesDirectory)/out/*.zip $(Build.ArtifactStagingDirectory) diff --git a/script/vsts/platforms/windows.yml b/script/vsts/platforms/windows.yml index b08c8a058..9e88e4211 100644 --- a/script/vsts/platforms/windows.yml +++ b/script/vsts/platforms/windows.yml @@ -3,6 +3,8 @@ phases: dependsOn: GetReleaseVersion variables: ReleaseVersion: $[ dependencies.GetReleaseVersion.outputs['Version.ReleaseVersion'] ] + IsReleaseBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsReleaseBranch'] ] + IsSignedZipBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsSignedZipBranch'] ] queue: name: Hosted timeoutInMinutes: 180 @@ -23,11 +25,24 @@ phases: - script: | IF NOT EXIST C:\tmp MKDIR C:\tmp SET SQUIRREL_TEMP=C:\tmp - script\build.cmd --create-windows-installer --code-sign --compress-artifacts + IF [%IS_RELEASE_BRANCH%]==[true] ( + ECHO Creating production artifacts for release branch %BUILD_SOURCEBRANCHNAME% + script\build.cmd --code-sign --compress-artifacts --create-windows-installer + ) ELSE ( + IF [%IS_SIGNED_ZIP_BRANCH%]==[true] ( + ECHO Creating signed CI artifacts for branch %BUILD_SOURCEBRANCHNAME% + script\build.cmd --code-sign --compress-artifacts + ) ELSE ( + ECHO Pull request build, no code signing will be performed + script\build.cmd --compress-artifacts + ) + ) env: ATOM_RELEASE_VERSION: $(ReleaseVersion) ATOM_WIN_CODE_SIGNING_CERT_DOWNLOAD_URL: $(ATOM_WIN_CODE_SIGNING_CERT_DOWNLOAD_URL) ATOM_WIN_CODE_SIGNING_CERT_PASSWORD: $(ATOM_WIN_CODE_SIGNING_CERT_PASSWORD) + IS_RELEASE_BRANCH: $(IsReleaseBranch) + IS_SIGNED_ZIP_BRANCH: $(IsSignedZipBranch) displayName: Build Atom - script: script\lint.cmd @@ -38,13 +53,7 @@ phases: CI: true CI_PROVIDER: VSTS displayName: Run tests - - - task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: $(Build.SourcesDirectory)/out/AtomSetup-x64.exe - ArtifactName: AtomSetup-x64.exe - ArtifactType: Container - displayName: Upload AtomSetup-x64.exe + condition: and(succeeded(), ne(variables['Atom.SkipTests'], 'true')) - task: PublishBuildArtifacts@1 inputs: @@ -53,12 +62,21 @@ phases: ArtifactType: Container displayName: Upload atom-x64-windows.zip + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: $(Build.SourcesDirectory)/out/AtomSetup-x64.exe + ArtifactName: AtomSetup-x64.exe + ArtifactType: Container + displayName: Upload AtomSetup-x64.exe + condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true')) + - task: PublishBuildArtifacts@1 inputs: PathtoPublish: $(Build.SourcesDirectory)/out/atom-x64-$(ReleaseVersion)-full.nupkg ArtifactName: atom-x64-$(ReleaseVersion)-full.nupkg ArtifactType: Container displayName: Upload atom-x64-$(ReleaseVersion)-full.nupkg + condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true')) - task: PublishBuildArtifacts@1 inputs: @@ -66,3 +84,4 @@ phases: ArtifactName: RELEASES-x64 ArtifactType: Container displayName: Upload RELEASES-x64 + condition: and(succeeded(), eq(variables['IsReleaseBranch'], 'true')) diff --git a/script/vsts/pull-requests.yml b/script/vsts/pull-requests.yml new file mode 100644 index 000000000..8f17bacff --- /dev/null +++ b/script/vsts/pull-requests.yml @@ -0,0 +1,19 @@ +trigger: none # No CI builds, only PR builds + +phases: + +- phase: GetReleaseVersion + steps: + # This has to be done separately because VSTS inexplicably + # exits the script block after `npm install` completes. + - script: | + cd script\vsts + npm install + displayName: npm install + - script: node script\vsts\get-release-version.js + name: Version + +# Import OS-specific build definitions +- template: platforms/windows.yml +- template: platforms/macos.yml +- template: platforms/linux.yml diff --git a/script/vsts/release-branch-build.yml b/script/vsts/release-branch-build.yml index 8ef4c50d7..a1fa52940 100644 --- a/script/vsts/release-branch-build.yml +++ b/script/vsts/release-branch-build.yml @@ -19,3 +19,45 @@ phases: #- template: platforms/windows.yml - template: platforms/macos.yml - template: platforms/linux.yml + +- phase: UploadArtifacts + queue: Hosted # Need this for Python 2.7 + condition: and(succeeded(), eq(variables['IsSignedZipBranch'], 'true')) + + dependsOn: + - GetReleaseVersion + # - Windows + - Linux + - macOS + + variables: + ReleaseVersion: $[ dependencies.GetReleaseVersion.outputs['Version.ReleaseVersion'] ] + IsReleaseBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsReleaseBranch'] ] + IsSignedZipBranch: $[ dependencies.GetReleaseVersion.outputs['Version.IsSignedZipBranch'] ] + + steps: + - task: NodeTool@0 + inputs: + versionSpec: 8.9.3 + displayName: Install Node.js 8.9.3 + + # This has to be done separately because VSTS inexplicably + # exits the script block after `npm install` completes. + - script: | + cd script + npm install + displayName: npm install + + - task: DownloadBuildArtifacts@0 + displayName: Download Release Artifacts + inputs: + artifactName: Binaries + + - script: | + $(Build.SourcesDirectory)\script\publish-release.cmd --assets-path "$(System.ArtifactsDirectory)/Binaries" --s3-path "vsts-artifacts/$(Build.BuildNumber)" + env: + ATOM_RELEASE_VERSION: $(ReleaseVersion) + ATOM_RELEASES_S3_KEY: $(ATOM_RELEASES_S3_KEY) + ATOM_RELEASES_S3_SECRET: $(ATOM_RELEASES_S3_SECRET) + ATOM_RELEASES_S3_BUCKET: $(ATOM_RELEASES_S3_BUCKET) + displayName: Upload CI Artifacts to S3