From c7fada490aceb4e800d68368a213272cacd760ef Mon Sep 17 00:00:00 2001 From: Chris Jordan Date: Wed, 16 Aug 2023 09:35:23 -0400 Subject: [PATCH] added version.json --- .github/workflows/build.yml | 12 +++++++++--- config/esbuild.js | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad5443ab8f..84b0fdcaee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,9 +26,6 @@ jobs: - run: npm install - name: Typecheck with TypeScript run: npm run typecheck - - name: Build client bundles - run: node ./config/esbuild-cli.js --config=min --no-typecheck --define STATE_SERVERS=$(cat config/state_servers.json | tr -d " \t\n\r") - - run: cp -r ./dist/min appengine/frontend/static/ - name: Get branch name (merge) if: github.event_name != 'pull_request' shell: bash @@ -38,6 +35,15 @@ jobs: shell: bash run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV - run: echo "BRANCH_NAME_URL=$(echo ${{ env.BRANCH_NAME }} | tr / - | tr _ -)" >> $GITHUB_ENV + - name: Get build info + run: echo "BUILD_INFO={'tag':'$(git describe --always --tags)', 'url':'https://github.com/${{github.repository}}/commit/$(git rev-parse HEAD)', 'timestamp':'$(date)', 'branch':'${{github.repository}}/${{env.BRANCH_NAME}}'}" >> $GITHUB_ENV + shell: bash + - name: Write build info + run: echo ${{ env.BUILD_INFO }} >> src/version.json + shell: bash + - name: Build client bundles + run: node ./config/esbuild-cli.js --config=min --no-typecheck --define STATE_SERVERS=$(cat config/state_servers.json | tr -d " \t\n\r") --define NEUROGLANCER_BUILD_INFO="${{ env.BUILD_INFO }}" + - run: cp -r ./dist/min appengine/frontend/static/ - name: start deployment uses: bobheadxi/deployments@v1 id: deployment diff --git a/config/esbuild.js b/config/esbuild.js index eb9423ea60..b0715e4670 100644 --- a/config/esbuild.js +++ b/config/esbuild.js @@ -143,6 +143,15 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= await fs.promises.writeFile(path.resolve(this.outDir, 'index.html'), indexHtml); } + async writeInfo() { + if (this.define.NEUROGLANCER_BUILD_INFO) { + await fs.promises.writeFile(path.resolve(this.outDir, 'version.json'), this.define.NEUROGLANCER_BUILD_INFO); + } + if (this.define.STATE_SERVERS) { + await fs.promises.writeFile(path.resolve(this.outDir, 'state_servers.json'), this.define.STATE_SERVERS); + } + } + getBaseEsbuildConfig() { return { outdir: this.outDir, @@ -187,6 +196,7 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= async buildNonModule() { await this.writeIndex(); + await this.writeInfo(); if (!this.python) { await fs.promises.copyFile( path.resolve(this.srcDir, 'neuroglancer/datasource/boss/bossauth.html'),