Skip to content

Commit e7e762d

Browse files
committed
ci: generate custom version name for dev + main tags
1 parent 8e98c1c commit e7e762d

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

.github/workflows/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
run: npm test
1616
- name: Build the interface
1717
run: npm run build
18+
env:
19+
DEVELOPMENT_BUILD: ${{ github.sha }}
1820
- name: Set up QEMU
1921
uses: docker/setup-qemu-action@v1
2022
- name: Set up Docker Buildx

.github/workflows/pull_request.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ jobs:
1616
run: npm test
1717
- name: Build the interface
1818
run: npm run build
19+
env:
20+
DEVELOPMENT_BUILD: ${{ github.event.pull_request.head.sha }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ _site
77
*.orig
88
.serve/
99
demo/v2
10+
.version.json

rollup.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,24 @@ import copyTransform from './rollup/copy-transform.js';
1414
import license from './rollup/license.js';
1515
import checkOutput from './rollup/check-output.js';
1616
import importSVG from './rollup/import-svg.js';
17+
import fs from 'fs';
18+
const version = JSON.parse(fs.readFileSync('./package.json', 'utf-8')).version;
1719

1820
const useServe = process.env.ROLLUP_SERVE === 'true';
1921
const output = useServe ? '.serve' : 'dist';
2022

23+
const getVersion = (version) => {
24+
const parts = version.split('.').map((e) => parseInt(e));
25+
if (useServe || process.env.DEVELOPMENT_BUILD) {
26+
parts[1]++;
27+
parts[2] = 0;
28+
return parts.join('.') + (useServe ? '-dev' : `-${process.env.DEVELOPMENT_BUILD.slice(0, 10)}`);
29+
}
30+
return version;
31+
};
32+
33+
fs.writeFileSync('.version.json', JSON.stringify({ version: getVersion(version) }));
34+
2135
const plugins = [
2236
riot(),
2337
json(),

src/components/docker-registry-ui.riot

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
128128
</material-footer>
129129
</footer>
130130
<script>
131-
import { version } from '../../package.json';
131+
import { version } from '../../.version.json';
132132
import { Router, Route } from '@riotjs/route';
133133
import Catalog from './catalog/catalog.riot';
134134
import TagList from './tag-list/tag-list.riot';

0 commit comments

Comments
 (0)