-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: upload release packages as job artifacts for PRs
Upload release packages as job artifacts for PRs. This allows us to easily check out changes from a PR locally, without having to manually check-out the branch, and building the release output. Co-authored-by: George Kalpakas <kalpakas.g@gmail.com>
- Loading branch information
1 parent
ef16735
commit 2c55217
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Script that creates tar archives of built release packages. These archives can then | ||
* be uploaded to the CircleCI artifacts so that PRs or individual commits can be easily | ||
* tested out without having to build the release packages manually, and packing them up. | ||
* | ||
* This is different to the snapshot builds repositories as those only are available for | ||
* the primary `cdk` and `material` packages, and also don't run for pull requests. | ||
*/ | ||
|
||
const {join} = require('path'); | ||
const {rm, mkdir, test, ls, set, exec, cd} = require('shelljs'); | ||
const {red, green} = require('chalk'); | ||
const minimist = require('minimist'); | ||
|
||
const projectDir = join(__dirname, '../'); | ||
const archivesDir = 'dist/release-archives'; | ||
const releasesDir = 'dist/releases'; | ||
let {suffix} = minimist(process.argv.slice(2), {string: ['suffix']}); | ||
|
||
if (!suffix) { | ||
console.error(red('No suffix specified. Pass one with --suffix <text>')); | ||
process.exit(1); | ||
} | ||
|
||
// Fail if any ShellJS command fails. | ||
set('-e'); | ||
|
||
cd(projectDir); | ||
|
||
if (!test('-e', releasesDir)) { | ||
console.error(red('The release output has not been built.')); | ||
process.exit(1); | ||
} | ||
|
||
rm('-Rf', archivesDir); | ||
mkdir('-p', archivesDir); | ||
|
||
const builtPackages = ls(releasesDir) | ||
.map(name => ({name, path: join(releasesDir, name)})) | ||
.filter(pkg => test('-d', pkg.path)); | ||
|
||
// If multiple packages should be archived, we also generate a single archive that | ||
// contains all packages. This makes it easier to transfer the release packages. | ||
if (builtPackages.length > 1) { | ||
console.info('Creating archive with all packages..'); | ||
exec(`tar --create --gzip --directory ${releasesDir} --file ${archivesDir}/all-${suffix}.tgz .`); | ||
} | ||
|
||
for (const pkg of builtPackages) { | ||
console.info(`Creating archive for package: ${pkg.name}`); | ||
exec(`tar --create --gzip --directory ${pkg.path} --file ${archivesDir}/${pkg.name}-${suffix}.tgz .`); | ||
} | ||
|
||
console.info(green(`Created package archives in: ${archivesDir}`)); |