1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-30 20:39:46 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Laurent Cozic
8b0b186fbc stdout 2021-11-24 16:48:56 +00:00
Laurent Cozic
a72d2b8da0 test 2021-11-24 13:47:46 +00:00
Laurent Cozic
1bdfc3bf03 test 2021-11-24 12:14:14 +00:00
Laurent Cozic
88cc0b12e1 test 2021-11-24 11:44:41 +00:00
Laurent Cozic
01470320f9 test 2021-11-24 11:09:39 +00:00
Laurent Cozic
04bc579d09 test 2021-11-24 11:05:31 +00:00
Laurent Cozic
2a98531c1a support for arm 2021-11-24 10:58:57 +00:00
5 changed files with 51 additions and 17 deletions

View File

@@ -28,12 +28,17 @@ else
IS_MACOS=1
fi
if [ "$HAS_DOCKER_LABEL" == "true" ]; then
HAS_DOCKER_LABEL=1
fi
# =============================================================================
# Print environment
# =============================================================================
echo "GITHUB_WORKFLOW=$GITHUB_WORKFLOW"
echo "GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME"
echo "HAS_DOCKER_LABEL=$HAS_DOCKER_LABEL"
echo "GITHUB_REF=$GITHUB_REF"
echo "RUNNER_OS=$RUNNER_OS"
echo "GIT_TAG_NAME=$GIT_TAG_NAME"
@@ -155,11 +160,15 @@ fi
cd "$ROOT_DIR/packages/app-desktop"
if [[ $GIT_TAG_NAME = v* ]]; then
if [[ $HAS_DOCKER_LABEL = 1 ]] && [[ $IS_LINUX = 1 ]] && [[ $IS_PULL_REQUEST = 1 ]]; then
echo "Step: Building Docker image for testing only (no publishing)"
cd "$ROOT_DIR"
npm run buildServerDocker -- --tag-name server-v0.0.0
elif [[ $GIT_TAG_NAME = v* ]]; then
echo "Step: Building and publishing desktop application..."
USE_HARD_LINKS=false npm run dist
elif [[ $GIT_TAG_NAME = server-v* ]] && [[ $IS_LINUX = 1 ]]; then
echo "Step: Building Docker Image..."
echo "Step: Building and publishing Docker image..."
cd "$ROOT_DIR"
npm run buildServerDocker -- --tag-name $GIT_TAG_NAME --push-images
else

View File

@@ -28,8 +28,12 @@ jobs:
brew install gettext
brew install translate-toolkit
# If a pull request is tagged with the "docker" label, we build the image
# so that it's possible to check that it works. However we don't push the
# tags to Docker Hub. We only do that if we're on a tag "server-vX.Y.Z".
- name: Install Docker Engine
if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/server-v')
if: runner.os == 'Linux' && (startsWith(github.ref, 'refs/tags/server-v') || contains(github.event.pull_request.labels.*.name, 'docker'))
run: |
sudo apt-get install -y apt-transport-https
sudo apt-get install -y ca-certificates
@@ -43,6 +47,15 @@ jobs:
sudo apt-get update || true
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Enables support for ARM64 architecture
# https://hub.docker.com/r/tonistiigi/binfmt
docker run --privileged --rm tonistiigi/binfmt --install arm64,arm
# Need to create and switch to a different driver because
# multiple platforms feature may not be enabled on the
# default driver.
docker buildx create --name crossplatformbuild --use
- uses: actions/checkout@v2
- uses: olegtarasov/get-tag@v2.1
- uses: actions/setup-node@v2
@@ -68,6 +81,7 @@ jobs:
CSC_LINK: ${{ secrets.APPLE_CSC_LINK }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
IS_CONTINUOUS_INTEGRATION: 1
HAS_DOCKER_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'docker') }}
run: |
"${GITHUB_WORKSPACE}/.github/scripts/run_ci.sh"

View File

@@ -44,7 +44,7 @@ async function checkPluginRepository(dirPath: string, dryRun: boolean) {
async function extractPluginFilesFromPackage(existingManifests: any, workDir: string, packageName: string, destDir: string): Promise<any> {
const previousDir = chdir(workDir);
await execCommand2(`npm install ${packageName} --save --ignore-scripts`, { showOutput: false });
await execCommand2(`npm install ${packageName} --save --ignore-scripts`, { showStdout: false });
const pluginDir = resolveRelativePathWithinDir(workDir, 'node_modules', packageName, 'publish');
@@ -192,8 +192,8 @@ async function processNpmPackage(npmPackage: NpmPackage, repoDir: string, dryRun
if (!dryRun) {
if (!(await gitRepoClean())) {
await execCommand2('git add -A', { showOutput: false });
await execCommand2(['git', 'commit', '-m', commitMessage(actionType, manifest, previousManifest, npmPackage, error)], { showOutput: false });
await execCommand2('git add -A', { showStdout: false });
await execCommand2(['git', 'commit', '-m', commitMessage(actionType, manifest, previousManifest, npmPackage, error)], { showStdout: false });
} else {
console.info('Nothing to commit');
}
@@ -219,14 +219,14 @@ async function commandBuild(args: CommandBuildArgs) {
if (!dryRun) {
if (!(await gitRepoClean())) {
console.info('Updating README...');
await execCommand2('git add -A', { showOutput: true });
await execCommand2('git commit -m "Update README"', { showOutput: true });
await execCommand2('git add -A', { showStdout: true });
await execCommand2('git commit -m "Update README"', { showStdout: true });
}
}
chdir(previousDir);
const searchResults = (await execCommand2('npm search joplin-plugin --searchlimit 5000 --json', { showOutput: false })).trim();
const searchResults = (await execCommand2('npm search joplin-plugin --searchlimit 5000 --json', { showStdout: false })).trim();
const npmPackages = pluginInfoFromSearchResults(JSON.parse(searchResults));
for (const npmPackage of npmPackages) {
@@ -237,8 +237,8 @@ async function commandBuild(args: CommandBuildArgs) {
await commandUpdateRelease(args);
if (!(await gitRepoClean())) {
await execCommand2('git add -A', { showOutput: true });
await execCommand2('git commit -m "Update stats"', { showOutput: true });
await execCommand2('git add -A', { showStdout: true });
await execCommand2('git commit -m "Update stats"', { showStdout: true });
}
await execCommand2('git push');

View File

@@ -20,13 +20,14 @@ async function main() {
if (!argv.tagName) throw new Error('--tag-name not provided');
const pushImages = !!argv.pushImages;
const tagName = argv.tagName;
const isPreRelease = getIsPreRelease(tagName);
const imageVersion = getVersionFromTag(tagName, isPreRelease);
const buildDate = moment(new Date().getTime()).format('YYYY-MM-DDTHH:mm:ssZ');
let revision = '';
try {
revision = await execCommand2('git rev-parse --short HEAD', { showOutput: false });
revision = await execCommand2('git rev-parse --short HEAD', { showStdout: false });
} catch (error) {
console.info('Could not get git commit: metadata revision field will be empty');
}
@@ -41,13 +42,19 @@ async function main() {
process.chdir(rootDir);
console.info(`Running from: ${process.cwd()}`);
const platforms = [
'linux/amd64',
'linux/arm64',
];
console.info('tagName:', tagName);
console.info('pushImages:', pushImages);
console.info('imageVersion:', imageVersion);
console.info('isPreRelease:', isPreRelease);
console.info('Platforms:', platforms.join(', '));
console.info('Docker tags:', dockerTags.join(', '));
await execCommand2(`docker build -t "joplin/server:${imageVersion}" ${buildArgs} -f Dockerfile.server .`);
await execCommand2(`docker buildx build --progress=plain --platform ${platforms.join(',')} -t "joplin/server:${imageVersion}" ${buildArgs} -f Dockerfile.server .`);
for (const tag of dockerTags) {
await execCommand2(`docker tag "joplin/server:${imageVersion}" "joplin/server:${tag}"`);
if (pushImages) await execCommand2(`docker push joplin/server:${tag}`);

View File

@@ -146,7 +146,8 @@ export function execCommandVerbose(commandName: string, args: string[] = []) {
interface ExecCommandOptions {
showInput?: boolean;
showOutput?: boolean;
showStdout?: boolean;
showStderr?: boolean;
quiet?: boolean;
}
@@ -159,14 +160,16 @@ interface ExecCommandOptions {
export async function execCommand2(command: string | string[], options: ExecCommandOptions = null): Promise<string> {
options = {
showInput: true,
showOutput: true,
showStdout: true,
showStderr: true,
quiet: false,
...options,
};
if (options.quiet) {
options.showInput = false;
options.showOutput = false;
options.showStdout = false;
options.showStderr = false;
}
if (options.showInput) {
@@ -181,7 +184,8 @@ export async function execCommand2(command: string | string[], options: ExecComm
const executableName = args[0];
args.splice(0, 1);
const promise = execa(executableName, args);
if (options.showOutput) promise.stdout.pipe(process.stdout);
if (options.showStdout) promise.stdout.pipe(process.stdout);
if (options.showStderr) promise.stdout.pipe(process.stderr);
const result = await promise;
return result.stdout.trim();
}