From e7e762d6d9e97b95e4e3a188b93ab13e1543b985 Mon Sep 17 00:00:00 2001 From: Joxit Date: Wed, 24 May 2023 23:38:06 +0200 Subject: [PATCH] ci: generate custom version name for dev + `main` tags --- .github/workflows/main.yml | 2 ++ .github/workflows/pull_request.yml | 2 ++ .gitignore | 1 + rollup.config.js | 14 ++++++++++++++ src/components/docker-registry-ui.riot | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index df39aa7..4791df7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,8 @@ jobs: run: npm test - name: Build the interface run: npm run build + env: + DEVELOPMENT_BUILD: ${{ github.sha }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9ab1cf6..2f520de 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -16,3 +16,5 @@ jobs: run: npm test - name: Build the interface run: npm run build + env: + DEVELOPMENT_BUILD: ${{ github.event.pull_request.head.sha }} diff --git a/.gitignore b/.gitignore index 0ae01d3..78ba11c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ _site *.orig .serve/ demo/v2 +.version.json diff --git a/rollup.config.js b/rollup.config.js index ac1d2a4..0031df5 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -14,10 +14,24 @@ import copyTransform from './rollup/copy-transform.js'; import license from './rollup/license.js'; import checkOutput from './rollup/check-output.js'; import importSVG from './rollup/import-svg.js'; +import fs from 'fs'; +const version = JSON.parse(fs.readFileSync('./package.json', 'utf-8')).version; const useServe = process.env.ROLLUP_SERVE === 'true'; const output = useServe ? '.serve' : 'dist'; +const getVersion = (version) => { + const parts = version.split('.').map((e) => parseInt(e)); + if (useServe || process.env.DEVELOPMENT_BUILD) { + parts[1]++; + parts[2] = 0; + return parts.join('.') + (useServe ? '-dev' : `-${process.env.DEVELOPMENT_BUILD.slice(0, 10)}`); + } + return version; +}; + +fs.writeFileSync('.version.json', JSON.stringify({ version: getVersion(version) })); + const plugins = [ riot(), json(), diff --git a/src/components/docker-registry-ui.riot b/src/components/docker-registry-ui.riot index 8209856..5f39d37 100644 --- a/src/components/docker-registry-ui.riot +++ b/src/components/docker-registry-ui.riot @@ -128,7 +128,7 @@ along with this program. If not, see .