From 58a0dc4afe9c5150c5ab6a3bdbf86967a05b5d22 Mon Sep 17 00:00:00 2001
From: Isaac Abadi
Date: Mon, 20 Sep 2021 22:04:46 -0600
Subject: [PATCH] Version and commit info is now generated during autobuilds
and can be viewed in the about dialog
Prepared removal of JSON translations from repo to move towards XLIFF-only
---
.github/workflows/build.yml | 17 +++++++++++++++++
.github/workflows/docker-release.yml | 17 +++++++++++++++++
.github/workflows/docker.yml | 17 +++++++++++++++++
backend/app.js | 12 ++++++++++++
src/app/app.component.ts | 4 ++++
.../about-dialog/about-dialog.component.html | 11 +++++++++++
.../about-dialog/about-dialog.component.ts | 2 +-
src/app/posts.services.ts | 5 +++++
8 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8527313..54b21d0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -25,6 +25,23 @@ jobs:
cd backend
npm install
sudo npm install -g @angular/cli
+ - name: prepare localization
+ run: |
+ sudo npm install -g xliff-to-json
+ xliff-to-json ./src/assets/i18n
+ - name: Set hash
+ id: vars
+ run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+ - name: Get current date
+ id: date
+ run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
+ - name: create-json
+ id: create-json
+ uses: jsdaniell/create-json@1.1.2
+ with:
+ name: "version.json"
+ json: '{"type": "autobuild", "tag": "N/A", "commit": "${{ steps.vars.outputs.sha_short }}", "date": "${{ steps.date.outputs.date }}"}'
+ dir: 'backend/'
- name: build
run: ng build --prod
- name: prepare artifact upload
diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml
index 96ec2c8..aae7fb3 100644
--- a/.github/workflows/docker-release.yml
+++ b/.github/workflows/docker-release.yml
@@ -13,6 +13,23 @@ jobs:
steps:
- name: checkout code
uses: actions/checkout@v2
+ - name: prepare localization
+ run: |
+ sudo npm install -g xliff-to-json
+ xliff-to-json ./src/assets/i18n
+ - name: Set hash
+ id: vars
+ run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+ - name: Get current date
+ id: date
+ run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
+ - name: create-json
+ id: create-json
+ uses: jsdaniell/create-json@1.1.2
+ with:
+ name: "version.json"
+ json: '{"type": "docker", "tag": "latest", "commit": "${{ steps.vars.outputs.sha_short }}", "date": "${{ steps.date.outputs.date }}"}'
+ dir: 'backend/'
- name: setup platform emulator
uses: docker/setup-qemu-action@v1
- name: setup multi-arch docker build
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index c74f29b..9e0049b 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -10,6 +10,23 @@ jobs:
steps:
- name: checkout code
uses: actions/checkout@v2
+ - name: prepare localization
+ run: |
+ sudo npm install -g xliff-to-json
+ xliff-to-json ./src/assets/i18n
+ - name: Set hash
+ id: vars
+ run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+ - name: Get current date
+ id: date
+ run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
+ - name: create-json
+ id: create-json
+ uses: jsdaniell/create-json@1.1.2
+ with:
+ name: "version.json"
+ json: '{"type": "docker", "tag": "nightly", "commit": "${{ steps.vars.outputs.sha_short }}", "date": "${{ steps.date.outputs.date }}"}'
+ dir: 'backend/'
- name: setup platform emulator
uses: docker/setup-qemu-action@v1
- name: setup multi-arch docker build
diff --git a/backend/app.js b/backend/app.js
index 7404f3c..33363d9 100644
--- a/backend/app.js
+++ b/backend/app.js
@@ -142,6 +142,14 @@ var validDownloadingAgents = [
const subscription_timeouts = {};
+let version_info = null;
+if (fs.existsSync('version.json')) {
+ version_info = fs.readJSONSync('version.json');
+ logger.verbose(`Version info: ${JSON.stringify(version_info, null, 2)}`);
+} else {
+ version_info = {'type': 'N/A', 'tag': 'N/A', 'commit': 'N/A', 'date': 'N/A'};
+}
+
// don't overwrite config if it already happened.. NOT
// let alreadyWritten = db.get('configWriteFlag').value();
let writeConfigMode = process.env.write_ytdl_config;
@@ -932,6 +940,10 @@ app.post('/api/setConfig', optionalJwt, function(req, res) {
}
});
+app.get('/api/versionInfo', (req, res) => {
+ res.send({version_info: version_info});
+});
+
app.post('/api/restartServer', optionalJwt, (req, res) => {
// delayed by a little bit so that the client gets a response
setTimeout(() => {restartServer()}, 100);
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index cadd7ca..6780813 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -118,6 +118,10 @@ export class AppComponent implements OnInit, AfterViewInit {
}
this.postsService.reloadCategories();
+
+ this.postsService.getVersionInfo().subscribe(res => {
+ this.postsService.version_info = res['version_info'];
+ });
}
// theme stuff
diff --git a/src/app/dialogs/about-dialog/about-dialog.component.html b/src/app/dialogs/about-dialog/about-dialog.component.html
index ddf28f0..c869b8d 100644
--- a/src/app/dialogs/about-dialog/about-dialog.component.html
+++ b/src/app/dialogs/about-dialog/about-dialog.component.html
@@ -21,6 +21,17 @@
done Update available - {{latestGithubRelease['tag_name']}}. You can update from the settings menu.
You are up to date.
+
+ Installation type: {{postsService.version_info.type}}
+
+
+ Docker tag: {{postsService.version_info.tag}}
+
+
+ Commit hash: {{postsService.version_info.commit}}
+
+ Build date: {{postsService.version_info.date}}
+
Found a bug or have a suggestion? Click here to create an issue!
diff --git a/src/app/dialogs/about-dialog/about-dialog.component.ts b/src/app/dialogs/about-dialog/about-dialog.component.ts
index fb8c1fa..826421a 100644
--- a/src/app/dialogs/about-dialog/about-dialog.component.ts
+++ b/src/app/dialogs/about-dialog/about-dialog.component.ts
@@ -19,7 +19,7 @@ export class AboutDialogComponent implements OnInit {
sidepanel_mode = this.postsService.sidepanel_mode;
card_size = this.postsService.card_size;
- constructor(private postsService: PostsService) { }
+ constructor(public postsService: PostsService) { }
ngOnInit(): void {
this.getLatestGithubRelease();
diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts
index c0c8b56..22faa70 100644
--- a/src/app/posts.services.ts
+++ b/src/app/posts.services.ts
@@ -60,6 +60,7 @@ export class PostsService implements CanActivate {
categories = null;
sidenav = null;
locale = isoLangs['en'];
+ version_info = null;
constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document,
public snackBar: MatSnackBar, private titleService: Title) {
@@ -453,6 +454,10 @@ export class PostsService implements CanActivate {
return this.http.post(this.path + 'clearFinishedDownloads', {}, this.httpOptions);
}
+ getVersionInfo() {
+ return this.http.get(this.path + 'versionInfo', this.httpOptions);
+ }
+
updateServer(tag) {
return this.http.post(this.path + 'updateServer', {tag: tag}, this.httpOptions);
}