Skip to content

Commit

Permalink
Add nightly build schedule and update dev version in prebuild script (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mewim authored Mar 25, 2024
1 parent e2f4561 commit 8945ddb
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ on:
branches:
- master

schedule:
# Schedule a nightly build two hours after publishing the daily build
# of kuzu (see https://github.com/kuzudb/kuzu/blob/master/.github/workflows/build-and-deploy.yml)
# The kuzu daily build is scheduled at 8:00 UTC. The two hours delay
# should give enough time for the kuzu build to finish.
- cron: "0 10 * * *"

workflow_dispatch:
inputs:
isNightly:
description: "Whether the build is a nightly build?"
required: true
default: "false"

jobs:
lint:
name: Lint
Expand All @@ -22,6 +36,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Prebuild - update dev version
if: ${{ github.event_name == 'schedule' || github.event.inputs.isNightly == 'true' }}
working-directory: scripts
run: node UpdateDevVersion
- name: Prebuild - install dependencies
run: npm install
- name: Prebuild - generate grammar
Expand All @@ -31,12 +49,20 @@ jobs:
- name: Prebuild - fetch datasets
run: npm run fetch-datasets
- name: Prebuild - cleanup
run: rm -rf node_modules
run: rm -rf node_modules .git
- name: Prebuild - get version
shell: bash
run: |
VERSION=$(node -e 'fs=require("fs");console.log(JSON.parse(fs.readFileSync("package.json")).dependencies.kuzu)')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Prebuild - set tag for nightly build
if: ${{ github.event_name == 'schedule' || github.event.inputs.isNightly == 'true' }}
run: echo "TAGS=kuzudb/explorer:dev" >> $GITHUB_ENV
- name: Prebuild - set tag for release build
if: ${{ github.event_name != 'schedule' && github.event.inputs.isNightly != 'true' }}
run: echo "TAGS=kuzudb/explorer:latest,kuzudb/explorer:${{ env.VERSION }}" >> $GITHUB_ENV
- name: Prebuild - show tags
run: echo $TAGS
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -52,7 +78,7 @@ jobs:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: kuzudb/explorer:latest, kuzudb/explorer:${{ env.VERSION }}
tags: ${{ env.TAGS }}
build-args: |
SKIP_GRAMMAR=true
SKIP_BUILD_APP=true
Expand Down
39 changes: 39 additions & 0 deletions scripts/UpdateDevVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const fs = require("fs");
const path = require("path");
const exec = require("child_process").exec;
const process = require("process");

const PACKAGE_JSON_PATH = path.resolve(__dirname, "../package.json");
const CMD = "npm view kuzu@next version";

(() => {
exec(CMD, (error, stdout, _) => {
if (error) {
console.error(`Failed to get latest dev version: ${error}`);
process.exit(1);
}
const latestVersion = stdout.trim();
console.log(`Latest dev version is ${latestVersion}`);
fs.readFile(PACKAGE_JSON_PATH, "utf8", (err, data) => {
console.log("Opened package.json at", PACKAGE_JSON_PATH);
if (err) {
console.error("Error reading package.json", err);
process.exit(1);
}
const packageJson = JSON.parse(data);
packageJson.dependencies.kuzu = `^${latestVersion}`;
fs.writeFile(
PACKAGE_JSON_PATH,
JSON.stringify(packageJson, null, 2),
(err) => {
if (err) {
console.error("Error writing package.json", err);
process.exit(1);
}
console.log(`Updated kuzu to ${latestVersion}`);
process.exit(0);
}
);
});
});
})();

0 comments on commit 8945ddb

Please sign in to comment.