mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Tools: Make server build more configurable
This commit is contained in:
parent
cc69cabf9b
commit
46490113a2
6
.github/scripts/run_ci.sh
vendored
6
.github/scripts/run_ci.sh
vendored
@ -38,6 +38,8 @@ echo "GITHUB_REF=$GITHUB_REF"
|
|||||||
echo "RUNNER_OS=$RUNNER_OS"
|
echo "RUNNER_OS=$RUNNER_OS"
|
||||||
echo "GIT_TAG_NAME=$GIT_TAG_NAME"
|
echo "GIT_TAG_NAME=$GIT_TAG_NAME"
|
||||||
echo "BUILD_SEQUENCIAL=$BUILD_SEQUENCIAL"
|
echo "BUILD_SEQUENCIAL=$BUILD_SEQUENCIAL"
|
||||||
|
echo "SERVER_REPOSITORY=$SERVER_REPOSITORY"
|
||||||
|
echo "SERVER_TAG_PREFIX=$SERVER_TAG_PREFIX"
|
||||||
|
|
||||||
echo "IS_CONTINUOUS_INTEGRATION=$IS_CONTINUOUS_INTEGRATION"
|
echo "IS_CONTINUOUS_INTEGRATION=$IS_CONTINUOUS_INTEGRATION"
|
||||||
echo "IS_PULL_REQUEST=$IS_PULL_REQUEST"
|
echo "IS_PULL_REQUEST=$IS_PULL_REQUEST"
|
||||||
@ -169,10 +171,10 @@ cd "$ROOT_DIR/packages/app-desktop"
|
|||||||
if [[ $GIT_TAG_NAME = v* ]]; then
|
if [[ $GIT_TAG_NAME = v* ]]; then
|
||||||
echo "Step: Building and publishing desktop application..."
|
echo "Step: Building and publishing desktop application..."
|
||||||
USE_HARD_LINKS=false yarn run dist
|
USE_HARD_LINKS=false yarn run dist
|
||||||
elif [[ $GIT_TAG_NAME = server-v* ]] && [[ $IS_LINUX = 1 ]]; then
|
elif [[ $IS_LINUX = 1 ]] && [[ $GIT_TAG_NAME = $SERVER_TAG_PREFIX-* ]]; then
|
||||||
echo "Step: Building Docker Image..."
|
echo "Step: Building Docker Image..."
|
||||||
cd "$ROOT_DIR"
|
cd "$ROOT_DIR"
|
||||||
yarn run buildServerDocker --tag-name $GIT_TAG_NAME --push-images
|
yarn run buildServerDocker --tag-name $GIT_TAG_NAME --push-images --repository $SERVER_REPOSITORY
|
||||||
else
|
else
|
||||||
echo "Step: Building but *not* publishing desktop application..."
|
echo "Step: Building but *not* publishing desktop application..."
|
||||||
USE_HARD_LINKS=false yarn run dist --publish=never
|
USE_HARD_LINKS=false yarn run dist --publish=never
|
||||||
|
4
.github/workflows/github-actions-main.yml
vendored
4
.github/workflows/github-actions-main.yml
vendored
@ -98,6 +98,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
IS_CONTINUOUS_INTEGRATION: 1
|
IS_CONTINUOUS_INTEGRATION: 1
|
||||||
BUILD_SEQUENCIAL: 1
|
BUILD_SEQUENCIAL: 1
|
||||||
|
SERVER_REPOSITORY: joplin/server
|
||||||
|
SERVER_TAG_PREFIX: server
|
||||||
run: |
|
run: |
|
||||||
yarn install && cd packages/app-desktop && yarn run dist --publish=never
|
yarn install && cd packages/app-desktop && yarn run dist --publish=never
|
||||||
|
|
||||||
@ -138,5 +140,5 @@ jobs:
|
|||||||
BUILD_SEQUENCIAL: 1
|
BUILD_SEQUENCIAL: 1
|
||||||
run: |
|
run: |
|
||||||
yarn install
|
yarn install
|
||||||
yarn run buildServerDocker --tag-name server-v0.0.0
|
yarn run buildServerDocker --tag-name server-v0.0.0 --repository joplin/server
|
||||||
|
|
@ -15,8 +15,6 @@ describe('buildServerDocker', function() {
|
|||||||
const actual = getVersionFromTag(tagName, isPreRelease);
|
const actual = getVersionFromTag(tagName, isPreRelease);
|
||||||
expect(actual).toBe(expected);
|
expect(actual).toBe(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(() => getVersionFromTag('app-cli-v1.0.0', false)).toThrow();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should check if it is a pre-release', async () => {
|
test('should check if it is a pre-release', async () => {
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
import { execCommand2, rootDir } from './tool-utils';
|
import { execCommand2, rootDir } from './tool-utils';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
|
||||||
|
interface Argv {
|
||||||
|
dryRun?: boolean;
|
||||||
|
pushImages?: boolean;
|
||||||
|
repository?: string;
|
||||||
|
tagName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export function getVersionFromTag(tagName: string, isPreRelease: boolean): string {
|
export function getVersionFromTag(tagName: string, isPreRelease: boolean): string {
|
||||||
if (tagName.indexOf('server-') !== 0) throw new Error(`Invalid tag: ${tagName}`);
|
|
||||||
const s = tagName.split('-');
|
const s = tagName.split('-');
|
||||||
const suffix = isPreRelease ? '-beta' : '';
|
const suffix = isPreRelease ? '-beta' : '';
|
||||||
return s[1].substr(1) + suffix;
|
return s[1].substr(1) + suffix;
|
||||||
@ -16,11 +22,13 @@ export function getIsPreRelease(_tagName: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const argv = require('yargs').argv;
|
const argv = require('yargs').argv as Argv;
|
||||||
if (!argv.tagName) throw new Error('--tag-name not provided');
|
if (!argv.tagName) throw new Error('--tag-name not provided');
|
||||||
|
if (!argv.repository) throw new Error('--repository not provided');
|
||||||
|
|
||||||
const dryRun = !!argv.dryRun;
|
const dryRun = !!argv.dryRun;
|
||||||
const pushImages = !!argv.pushImages;
|
const pushImages = !!argv.pushImages;
|
||||||
|
const repository = argv.repository;
|
||||||
const tagName = argv.tagName;
|
const tagName = argv.tagName;
|
||||||
const isPreRelease = getIsPreRelease(tagName);
|
const isPreRelease = getIsPreRelease(tagName);
|
||||||
const imageVersion = getVersionFromTag(tagName, isPreRelease);
|
const imageVersion = getVersionFromTag(tagName, isPreRelease);
|
||||||
@ -48,7 +56,7 @@ async function main() {
|
|||||||
console.info('isPreRelease:', isPreRelease);
|
console.info('isPreRelease:', isPreRelease);
|
||||||
console.info('Docker tags:', dockerTags.join(', '));
|
console.info('Docker tags:', dockerTags.join(', '));
|
||||||
|
|
||||||
const dockerCommand = `docker build --progress=plain -t "joplin/server:${imageVersion}" ${buildArgs} -f Dockerfile.server .`;
|
const dockerCommand = `docker build --progress=plain -t "${repository}:${imageVersion}" ${buildArgs} -f Dockerfile.server .`;
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
console.info(dockerCommand);
|
console.info(dockerCommand);
|
||||||
return;
|
return;
|
||||||
@ -57,8 +65,8 @@ async function main() {
|
|||||||
await execCommand2(dockerCommand);
|
await execCommand2(dockerCommand);
|
||||||
|
|
||||||
for (const tag of dockerTags) {
|
for (const tag of dockerTags) {
|
||||||
await execCommand2(`docker tag "joplin/server:${imageVersion}" "joplin/server:${tag}"`);
|
await execCommand2(`docker tag "${repository}:${imageVersion}" "${repository}:${tag}"`);
|
||||||
if (pushImages) await execCommand2(`docker push joplin/server:${tag}`);
|
if (pushImages) await execCommand2(`docker push ${repository}:${tag}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ enum Platform {
|
|||||||
Desktop = 'desktop',
|
Desktop = 'desktop',
|
||||||
Clipper = 'clipper',
|
Clipper = 'clipper',
|
||||||
Server = 'server',
|
Server = 'server',
|
||||||
|
Cloud = 'cloud',
|
||||||
Cli = 'cli',
|
Cli = 'cli',
|
||||||
PluginGenerator = 'plugin-generator',
|
PluginGenerator = 'plugin-generator',
|
||||||
PluginRepoCli = 'plugin-repo-cli',
|
PluginRepoCli = 'plugin-repo-cli',
|
||||||
@ -84,6 +85,7 @@ function platformFromTag(tagName: string): Platform {
|
|||||||
if (tagName.indexOf('clipper') === 0) return Platform.Clipper;
|
if (tagName.indexOf('clipper') === 0) return Platform.Clipper;
|
||||||
if (tagName.indexOf('cli') === 0) return Platform.Cli;
|
if (tagName.indexOf('cli') === 0) return Platform.Cli;
|
||||||
if (tagName.indexOf('server') === 0) return Platform.Server;
|
if (tagName.indexOf('server') === 0) return Platform.Server;
|
||||||
|
if (tagName.indexOf('cloud') === 0) return Platform.Cloud;
|
||||||
if (tagName.indexOf('plugin-generator') === 0) return Platform.PluginGenerator;
|
if (tagName.indexOf('plugin-generator') === 0) return Platform.PluginGenerator;
|
||||||
if (tagName.indexOf('plugin-repo-cli') === 0) return Platform.PluginRepoCli;
|
if (tagName.indexOf('plugin-repo-cli') === 0) return Platform.PluginRepoCli;
|
||||||
throw new Error(`Could not determine platform from tag: "${tagName}"`);
|
throw new Error(`Could not determine platform from tag: "${tagName}"`);
|
||||||
@ -115,7 +117,7 @@ function filterLogs(logs: LogEntry[], platform: Platform) {
|
|||||||
let addIt = false;
|
let addIt = false;
|
||||||
|
|
||||||
// "All" refers to desktop, CLI and mobile app. Clipper and Server are not included.
|
// "All" refers to desktop, CLI and mobile app. Clipper and Server are not included.
|
||||||
if (prefix.indexOf('all') >= 0 && (platform !== 'clipper' && platform !== 'server')) addIt = true;
|
if (prefix.indexOf('all') >= 0 && (platform !== 'clipper' && platform !== 'server' && platform !== 'cloud')) addIt = true;
|
||||||
if ((platform === 'android' || platform === 'ios') && prefix.indexOf('mobile') >= 0) addIt = true;
|
if ((platform === 'android' || platform === 'ios') && prefix.indexOf('mobile') >= 0) addIt = true;
|
||||||
if (platform === 'android' && prefix.indexOf('android') >= 0) addIt = true;
|
if (platform === 'android' && prefix.indexOf('android') >= 0) addIt = true;
|
||||||
if (platform === 'ios' && prefix.indexOf('ios') >= 0) addIt = true;
|
if (platform === 'ios' && prefix.indexOf('ios') >= 0) addIt = true;
|
||||||
@ -124,6 +126,7 @@ function filterLogs(logs: LogEntry[], platform: Platform) {
|
|||||||
if (platform === 'cli' && prefix.indexOf('cli') >= 0) addIt = true;
|
if (platform === 'cli' && prefix.indexOf('cli') >= 0) addIt = true;
|
||||||
if (platform === 'clipper' && prefix.indexOf('clipper') >= 0) addIt = true;
|
if (platform === 'clipper' && prefix.indexOf('clipper') >= 0) addIt = true;
|
||||||
if (platform === 'server' && prefix.indexOf('server') >= 0) addIt = true;
|
if (platform === 'server' && prefix.indexOf('server') >= 0) addIt = true;
|
||||||
|
if (platform === 'cloud' && prefix.indexOf('cloud') >= 0) addIt = true;
|
||||||
|
|
||||||
// Translation updates often comes in format "Translation: Update pt_PT.po"
|
// Translation updates often comes in format "Translation: Update pt_PT.po"
|
||||||
// but that's not useful in a changelog especially since most people
|
// but that's not useful in a changelog especially since most people
|
||||||
@ -155,7 +158,7 @@ function formatCommitMessage(commit: string, msg: string, author: Author, option
|
|||||||
const isPlatformPrefix = (prefixString: string) => {
|
const isPlatformPrefix = (prefixString: string) => {
|
||||||
const prefix = prefixString.split(',').map(p => p.trim().toLowerCase());
|
const prefix = prefixString.split(',').map(p => p.trim().toLowerCase());
|
||||||
for (const p of prefix) {
|
for (const p of prefix) {
|
||||||
if (['android', 'mobile', 'ios', 'desktop', 'cli', 'clipper', 'all', 'api', 'plugins', 'server'].indexOf(p) >= 0) return true;
|
if (['android', 'mobile', 'ios', 'desktop', 'cli', 'clipper', 'all', 'api', 'plugins', 'server', 'cloud'].indexOf(p) >= 0) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,9 @@ function commandToString(commandName: string, args: string[] = []) {
|
|||||||
return output.join(' ');
|
return output.join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function insertChangelog(tag: string, changelogPath: string, changelog: string, isPrerelease: boolean) {
|
async function insertChangelog(tag: string, changelogPath: string, changelog: string, isPrerelease: boolean, repoTagUrl: string = '') {
|
||||||
|
repoTagUrl = repoTagUrl || 'https://github.com/laurent22/joplin/releases/tag';
|
||||||
|
|
||||||
const currentText = await fs.readFile(changelogPath, 'UTF-8');
|
const currentText = await fs.readFile(changelogPath, 'UTF-8');
|
||||||
const lines = currentText.split('\n');
|
const lines = currentText.split('\n');
|
||||||
|
|
||||||
@ -60,7 +62,7 @@ async function insertChangelog(tag: string, changelogPath: string, changelog: st
|
|||||||
|
|
||||||
const header = [
|
const header = [
|
||||||
'##',
|
'##',
|
||||||
`[${tag}](https://github.com/laurent22/joplin/releases/tag/${tag})`,
|
`[${tag}](${repoTagUrl}/${tag})`,
|
||||||
];
|
];
|
||||||
if (isPrerelease) header.push('(Pre-release)');
|
if (isPrerelease) header.push('(Pre-release)');
|
||||||
header.push('-');
|
header.push('-');
|
||||||
@ -91,10 +93,10 @@ export function releaseFinalGitCommands(appName: string, newVersion: string, new
|
|||||||
return finalCmds.join(' && ');
|
return finalCmds.join(' && ');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function completeReleaseWithChangelog(changelogPath: string, newVersion: string, newTag: string, appName: string, isPreRelease: boolean) {
|
export async function completeReleaseWithChangelog(changelogPath: string, newVersion: string, newTag: string, appName: string, isPreRelease: boolean, repoTagUrl = '') {
|
||||||
const changelog = (await execCommand2(`node ${rootDir}/packages/tools/git-changelog ${newTag} --publish-format full`, { })).trim();
|
const changelog = (await execCommand2(`node ${rootDir}/packages/tools/git-changelog ${newTag} --publish-format full`, { })).trim();
|
||||||
|
|
||||||
const newChangelog = await insertChangelog(newTag, changelogPath, changelog, isPreRelease);
|
const newChangelog = await insertChangelog(newTag, changelogPath, changelog, isPreRelease, repoTagUrl);
|
||||||
|
|
||||||
await fs.writeFile(changelogPath, newChangelog);
|
await fs.writeFile(changelogPath, newChangelog);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user