Skip to content

Commit

Permalink
ci: generate custom version name for dev + main tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit committed May 24, 2023
1 parent 8e98c1c commit e7e762d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ _site
*.orig
.serve/
demo/v2
.version.json
14 changes: 14 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/components/docker-registry-ui.riot
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</material-footer>
</footer>
<script>
import { version } from '../../package.json';
import { version } from '../../.version.json';
import { Router, Route } from '@riotjs/route';
import Catalog from './catalog/catalog.riot';
import TagList from './tag-list/tag-list.riot';
Expand Down

0 comments on commit e7e762d

Please sign in to comment.