-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish source code in release assets
Signed-off-by: Omkar Phansopkar <omkarphansopkar@gmail.com>
- Loading branch information
Showing
5 changed files
with
59 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const os = require("os"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const archiver = require("archiver"); | ||
const version = require("./package.json").version; | ||
|
||
const archiveDirectory = "dist"; | ||
const platform = os.platform(); | ||
const arch = os.arch(); | ||
|
||
// Determine the packaging format based on the OS | ||
const isWindows = platform === "win32"; | ||
const archiveFormat = isWindows ? "zip" : "tar"; | ||
const archiveExtension = isWindows ? "zip" : "tar.gz"; | ||
|
||
console.log("Building source archive ..."); | ||
|
||
// Ensure that the archive destination directory exists | ||
if (!fs.existsSync(archiveDirectory)) { | ||
fs.mkdirSync(archiveDirectory); | ||
} | ||
|
||
// Create the archive file with the same name as the package directory | ||
const archiveFileName = `ScanCode-Workbench-${version}-${platform}-${arch}-src.${archiveExtension}`; | ||
const archiveFilePath = path.join(archiveDirectory, archiveFileName); | ||
const output = fs.createWriteStream(archiveFilePath); | ||
const archive = archiver(archiveFormat, { gzip: true }); | ||
|
||
output.on("close", () => { | ||
console.log(`Created source archive at ${archiveFilePath}`); | ||
}); | ||
|
||
archive.pipe(output); | ||
|
||
archive.glob("**/*", { | ||
dot: true, | ||
cwd: process.cwd(), | ||
ignore: ["dist/**", "out/**", ".git/**"], | ||
}); | ||
|
||
archive.finalize(); |
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