Skip to content

Commit 6d53bbb

Browse files
committed
Add display of version and build run
1 parent 627988c commit 6d53bbb

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

.github/workflows/build.yml

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ jobs:
2222
node-version: '22'
2323
cache: 'npm'
2424

25+
- name: Version
26+
run: |
27+
BASE_VERSION=$(npm run get-version --silent)
28+
# Remove last digit and dot, then append run number
29+
VERSION=$(echo $BASE_VERSION | sed 's/\.[0-9]*$/.'${{ github.run_number }}/)
30+
echo "VERSION=$VERSION" >> $GITHUB_ENV
31+
shell: bash
32+
33+
- name: Update package.json version
34+
run: npm version $VERSION --no-git-tag-version
35+
shell: bash
36+
2537
- name: Install dependencies
2638
run: npm ci
2739

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "angor-profile",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
77
"build": "ng build",
88
"watch": "ng build --watch --configuration development",
9-
"test": "ng test"
9+
"test": "ng test",
10+
"get-version": "node -p \"require('./package.json').version\""
1011
},
1112
"private": true,
1213
"dependencies": {

src/app/app.component.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
22
import { RouterOutlet, RouterLink } from '@angular/router';
33
import { CommonModule } from '@angular/common';
44
import { ThemeService } from './services/theme.service';
5+
import { environment } from '../environment';
56

67
@Component({
78
selector: 'app-root',
@@ -80,7 +81,7 @@ import { ThemeService } from './services/theme.service';
8081
</div>
8182
</div>
8283
<div class="footer-bottom">
83-
<p>&copy; 2024 Angor Profile. All rights reserved.</p>
84+
<p>&copy; 2024 Angor Profile. All rights reserved. Version {{ version }}.</p>
8485
</div>
8586
</footer>
8687
`,
@@ -226,6 +227,8 @@ import { ThemeService } from './services/theme.service';
226227
export class AppComponent {
227228
title = 'angor-profile';
228229

230+
version = environment.appVersion
231+
229232
constructor(public themeService: ThemeService) {}
230233

231234
toggleTheme() {

src/environment.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { version } from '../package.json';
2+
3+
export const environment = {
4+
appVersion: version,
5+
};

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"moduleResolution": "bundler",
1717
"importHelpers": true,
1818
"target": "ES2022",
19-
"module": "ES2022"
19+
"module": "ES2022",
20+
"resolveJsonModule": true
2021
},
2122
"angularCompilerOptions": {
2223
"enableI18nLegacyMessageIdFormat": false,

0 commit comments

Comments
 (0)