mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-10-26 11:08:40 +03:00
CI: Automatically rename binaries for Regular releases
Adds a renaming script to rename the binaries with our Regular release naming scheme, and updates the Cirrus config to run said renaming script. De-facto codifies our existing, officially unofficial naming scheme with a bit of automation. We can always revise this down the line if consensus changes for how to name these files. Just a little institutional knowledge to unburden team members with, via the (sometimes double-edged sword...) of automation.
This commit is contained in:
parent
9e0db5b054
commit
0dac1e514d
10
.cirrus.yml
10
.cirrus.yml
@ -36,6 +36,8 @@ linux_task:
|
||||
- yarn run build:apm
|
||||
build_binary_script:
|
||||
- yarn dist || yarn dist
|
||||
rename_binary_script:
|
||||
- node script/rename.js "Linux"
|
||||
binary_artifacts:
|
||||
path: ./binaries/*
|
||||
test_script:
|
||||
@ -91,6 +93,8 @@ arm_linux_task:
|
||||
- yarn run build:apm
|
||||
build_binary_script:
|
||||
- yarn dist || yarn dist
|
||||
rename_binary_script:
|
||||
- node script/rename.js "ARM.Linux"
|
||||
binary_artifacts:
|
||||
path: ./binaries/*
|
||||
test_script:
|
||||
@ -134,6 +138,8 @@ silicon_mac_task:
|
||||
build_binary_script:
|
||||
- export PATH="/opt/homebrew/bin:/opt/homebrew/opt/node@16/bin:$PATH"
|
||||
- yarn dist || yarn dist
|
||||
rename_binary_script:
|
||||
- node script/rename.js "Silicon.Mac"
|
||||
binary_artifacts:
|
||||
path: ./binaries/*
|
||||
test_script:
|
||||
@ -182,6 +188,8 @@ intel_mac_task:
|
||||
build_binary_script:
|
||||
- export PATH="/usr/local/opt/node@16/bin:/usr/local/bin:$PATH"
|
||||
- arch -x86_64 npx yarn dist || arch -x86_64 npx yarn dist
|
||||
rename_binary_script:
|
||||
- node script/rename.js "Intel.Mac"
|
||||
binary_artifacts:
|
||||
path: ./binaries/*
|
||||
test_script:
|
||||
@ -223,6 +231,8 @@ windows_task:
|
||||
build_binary_script:
|
||||
- sed -i -e "s/[0-9]*-dev/`date -u +%Y%m%d%H`/g" package.json
|
||||
- npx yarn dist || npx yarn dist || npx yarn dist
|
||||
rename_binary_script:
|
||||
- node script\rename.js "Windows"
|
||||
binary_artifacts:
|
||||
path: .\binaries\*
|
||||
test_script:
|
||||
|
44
script/rename.js
Normal file
44
script/rename.js
Normal file
@ -0,0 +1,44 @@
|
||||
console.log("Starting the binary renaming script...");
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const prefix = process.argv[2];
|
||||
|
||||
const pulsarVersion = require('../package.json').version
|
||||
|
||||
if (pulsarVersion.endsWith('-dev')) {
|
||||
console.log(`Based on the version string in package.json (${pulsarVersion}),`);
|
||||
console.log('we are not preparing a Regular release, so not renaming any binaries.');
|
||||
console.log('Exiting the binary renaming script.');
|
||||
} else {
|
||||
|
||||
// Warn about required prefix as first argument.
|
||||
// If prefix was not provided, print warning and do nothing else, exiting "cleanly" with status 0.
|
||||
if (typeof prefix !== "string" || prefix.length === 0) {
|
||||
console.log("A prefix is required. Pass the desired prefix as the first argument to this script.");
|
||||
console.log('Example usage: "node script/rename.js Windows"');
|
||||
console.log('or: "node script/rename.js ARM.Linux"');
|
||||
console.log("Exiting the binary renaming script.");
|
||||
} else {
|
||||
console.log(`Prefix is: ${prefix}`);
|
||||
|
||||
// Rename files under ./binaries/* that haven't already been renamed
|
||||
const fileNames = fs.readdirSync('./binaries');
|
||||
|
||||
fileNames.forEach((file) => {
|
||||
console.log(`Existing filename is: ${file}`);
|
||||
|
||||
// We use 'starting with "p" or "P"' as the heuristic
|
||||
// for whether or not the file has already been renamed (and thus prefixed) before.
|
||||
if (file.startsWith('p') || file.startsWith('P')) {
|
||||
let dest = `${prefix}.${file}`
|
||||
// Replace any spaces with periods in the resulting filenames
|
||||
dest = dest.replace(/ /g,".");
|
||||
console.log(`Renaming file from "${file}" to "${dest}"`);
|
||||
fs.renameSync(`./binaries/${file}`, `./binaries/${dest}`);
|
||||
} else {
|
||||
console.log('Filename does not start with "p" or "P". Skipping...');
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user