2021-06-11 18:24:59 +02:00
|
|
|
import { execCommand2, rootDir } from './tool-utils';
|
|
|
|
|
2021-06-19 16:14:19 +02:00
|
|
|
function getVersionFromTag(tagName: string, isPreRelease: boolean): string {
|
2021-06-11 18:24:59 +02:00
|
|
|
if (tagName.indexOf('server-') !== 0) throw new Error(`Invalid tag: ${tagName}`);
|
|
|
|
const s = tagName.split('-');
|
2021-06-19 16:14:19 +02:00
|
|
|
const suffix = isPreRelease ? '-beta' : '';
|
|
|
|
return s[1].substr(1) + suffix;
|
2021-06-11 18:24:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getIsPreRelease(tagName: string): boolean {
|
|
|
|
return tagName.indexOf('-beta') > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const argv = require('yargs').argv;
|
|
|
|
if (!argv.tagName) throw new Error('--tag-name not provided');
|
|
|
|
|
|
|
|
const tagName = argv.tagName;
|
|
|
|
const isPreRelease = getIsPreRelease(tagName);
|
2021-06-19 16:14:19 +02:00
|
|
|
const imageVersion = getVersionFromTag(tagName, isPreRelease);
|
2021-06-11 18:24:59 +02:00
|
|
|
|
|
|
|
process.chdir(rootDir);
|
|
|
|
console.info(`Running from: ${process.cwd()}`);
|
|
|
|
|
|
|
|
console.info('tagName:', tagName);
|
|
|
|
console.info('imageVersion:', imageVersion);
|
|
|
|
console.info('isPreRelease:', isPreRelease);
|
|
|
|
|
|
|
|
await execCommand2(`docker build -t "joplin/server:${imageVersion}" -f Dockerfile.server .`);
|
|
|
|
await execCommand2(`docker push joplin/server:${imageVersion}`);
|
|
|
|
|
2021-06-19 16:14:19 +02:00
|
|
|
if (!isPreRelease) {
|
|
|
|
await execCommand2(`docker tag "joplin/server:${imageVersion}" "joplin/server:latest"`);
|
|
|
|
await execCommand2('docker push joplin/server:latest');
|
|
|
|
}
|
2021-06-11 18:24:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main().catch((error) => {
|
|
|
|
console.error('Fatal error');
|
|
|
|
console.error(error);
|
|
|
|
process.exit(1);
|
|
|
|
});
|