Skip to content

Commit

Permalink
CI: option to skip upload (#99)
Browse files Browse the repository at this point in the history
Co-authored-by: Amin Yahyaabadi <[email protected]>
Co-authored-by: DeeDeeG <[email protected]>
  • Loading branch information
aminya and DeeDeeG authored Aug 22, 2020
1 parent 24504c8 commit 1958ff4
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 32 deletions.
15 changes: 11 additions & 4 deletions script/vsts/nightly-release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# workaround for https://bit.ly/2CK8itc
variables:
_ATOM_RELEASES_S3_KEY: $[ variables.ATOM_RELEASES_S3_KEY ]
_ATOM_RELEASES_S3_SECRET: $[ variables.ATOM_RELEASES_S3_SECRET ]
_ATOM_RELEASES_S3_BUCKET: $[ variables.ATOM_RELEASES_S3_BUCKET ]
_PACKAGE_CLOUD_API_KEY: $[ variables.PACKAGE_CLOUD_API_KEY ]

jobs:
# GetReleaseVersion for nightly release
- template: platforms/templates/get-release-version.yml
Expand Down Expand Up @@ -42,10 +49,10 @@ jobs:
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
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)
PACKAGE_CLOUD_API_KEY: $(PACKAGE_CLOUD_API_KEY)
ATOM_RELEASES_S3_KEY: $(_ATOM_RELEASES_S3_KEY)
ATOM_RELEASES_S3_SECRET: $(_ATOM_RELEASES_S3_SECRET)
ATOM_RELEASES_S3_BUCKET: $(_ATOM_RELEASES_S3_BUCKET)
PACKAGE_CLOUD_API_KEY: $(_PACKAGE_CLOUD_API_KEY)
displayName: Create Nightly Release
- job: bump_dependencies
displayName: Bump Dependencies
Expand Down
15 changes: 11 additions & 4 deletions script/vsts/release-branch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ trigger:
- electron-*
pr: none # no PR triggers

# workaround for https://bit.ly/2CK8itc
variables:
_ATOM_RELEASES_S3_KEY: $[ variables.ATOM_RELEASES_S3_KEY ]
_ATOM_RELEASES_S3_SECRET: $[ variables.ATOM_RELEASES_S3_SECRET ]
_ATOM_RELEASES_S3_BUCKET: $[ variables.ATOM_RELEASES_S3_BUCKET ]
_PACKAGE_CLOUD_API_KEY: $[ variables.PACKAGE_CLOUD_API_KEY ]

jobs:
# GetReleaseVersion
- template: platforms/templates/get-release-version.yml
Expand Down Expand Up @@ -47,10 +54,10 @@ jobs:
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
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)
PACKAGE_CLOUD_API_KEY: $(PACKAGE_CLOUD_API_KEY)
ATOM_RELEASES_S3_KEY: $(_ATOM_RELEASES_S3_KEY)
ATOM_RELEASES_S3_SECRET: $(_ATOM_RELEASES_S3_SECRET)
ATOM_RELEASES_S3_BUCKET: $(_ATOM_RELEASES_S3_BUCKET)
PACKAGE_CLOUD_API_KEY: $(_PACKAGE_CLOUD_API_KEY)
displayName: Create Draft Release
condition: and(succeeded(), eq(variables['Atom.AutoDraftRelease'], 'true'), eq(variables['IsReleaseBranch'], 'true'))
Expand Down
52 changes: 34 additions & 18 deletions script/vsts/upload-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,43 @@ async function uploadArtifacts() {
return;
}

console.log(
`Uploading ${
assets.length
} release assets for ${releaseVersion} to S3 under '${bucketPath}'`
);

await uploadToS3(
process.env.ATOM_RELEASES_S3_KEY,
process.env.ATOM_RELEASES_S3_SECRET,
process.env.ATOM_RELEASES_S3_BUCKET,
bucketPath,
assets
);
if (
process.env.ATOM_RELEASES_S3_KEY &&
process.env.ATOM_RELEASES_S3_SECRET &&
process.env.ATOM_RELEASES_S3_BUCKET
) {
console.log(
`Uploading ${
assets.length
} release assets for ${releaseVersion} to S3 under '${bucketPath}'`
);

if (argv.linuxRepoName) {
await uploadLinuxPackages(
argv.linuxRepoName,
process.env.PACKAGE_CLOUD_API_KEY,
releaseVersion,
await uploadToS3(
process.env.ATOM_RELEASES_S3_KEY,
process.env.ATOM_RELEASES_S3_SECRET,
process.env.ATOM_RELEASES_S3_BUCKET,
bucketPath,
assets
);
} else {
console.log(
'\nEnvironment variables "ATOM_RELEASES_S3_BUCKET", "ATOM_RELEASES_S3_KEY" and/or "ATOM_RELEASES_S3_SECRET" are not set, skipping S3 upload.'
);
}

if (argv.linuxRepoName) {
if (process.env.PACKAGE_CLOUD_API_KEY) {
await uploadLinuxPackages(
argv.linuxRepoName,
process.env.PACKAGE_CLOUD_API_KEY,
releaseVersion,
assets
);
} else {
console.log(
'\nEnvironment variable "PACKAGE_CLOUD_API_KEY" is not set, skipping PackageCloud upload.'
);
}
} else {
console.log(
'\nNo Linux package repo name specified, skipping Linux package upload.'
Expand Down
22 changes: 16 additions & 6 deletions script/vsts/upload-crash-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,19 @@ async function uploadCrashReports() {
}
}

// Wrap the call the async function and catch errors from its promise because
// Node.js doesn't yet allow use of await at the script scope
uploadCrashReports().catch(err => {
console.error('An error occurred while uploading crash reports:\n\n', err);
process.exit(1);
});
if (
process.env.ATOM_RELEASES_S3_KEY &&
process.env.ATOM_RELEASES_S3_SECRET &&
process.env.ATOM_RELEASES_S3_BUCKET
) {
// Wrap the call the async function and catch errors from its promise because
// Node.js doesn't yet allow use of await at the script scope
uploadCrashReports().catch(err => {
console.error('An error occurred while uploading crash reports:\n\n', err);
process.exit(1);
});
} else {
console.log(
'\n\nEnvironment variables "ATOM_RELEASES_S3_BUCKET", "ATOM_RELEASES_S3_KEY" and/or "ATOM_RELEASES_S3_SECRET" are not set, skipping S3 upload.'
);
}

0 comments on commit 1958ff4

Please sign in to comment.