Skip to content

Commit df35fab

Browse files
committed
Make Git tag the single source of app version
1 parent 302f616 commit df35fab

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

.github/workflows/deploy.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
cache: 'npm'
1717
- run: npm install
1818
- run: npm run build
19+
env:
20+
VITE_APP_VERSION: ${{ github.ref_name }}
1921
- name: Publish to Cloudflare Pages
2022
uses: cloudflare/wrangler-action@v3
2123
with:

package-lock.json

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

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "clouddia",
3-
"version": "0.4.4",
43
"description": "Online Diagram Editor",
54
"homepage": "https://clouddia.01397.dev/clouddia/",
65
"main": "src/main.ts",

src/App.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import View, { viewTypeString } from './components/View.js';
1414
import DiagramParser, { DiagramFile, Train } from './DiagramParser.js';
1515
import Encoding from 'encoding-japanese';
1616
import { Dialog, h, Menu } from './Util.js';
17-
import './styles/app.css'
17+
import './styles/app.css';
1818

1919
export interface SelectionObject {
2020
train?: Train;
@@ -95,7 +95,9 @@ export default class App {
9595
private menu: MenuItem[];
9696

9797
constructor(root: Element) {
98-
this.version = '0.4.4';
98+
this.version = import.meta.env.PROD
99+
? import.meta.env.VITE_APP_VERSION
100+
: 'dev-build';
99101
this.sidebarElm = h('aside', { id: 'sidebar' }, null);
100102
this.toolbarElm = h('div', { id: 'toolbar' }, null);
101103
this.tabbarElm = h('div', { id: 'tabbar' }, null);
@@ -222,7 +224,7 @@ export default class App {
222224
public save() {
223225
//const bom = new Uint8Array([0xef, 0xbb, 0xbf]);
224226
const unicodeArray: number[] = [];
225-
const oudiaString = this.data.saveAsOud('CloudDia v' + this.version);
227+
const oudiaString = this.data.saveAsOud('CloudDia ' + this.version);
226228
for (let i = 0; i < oudiaString.length; i++) {
227229
unicodeArray.push(oudiaString.charCodeAt(i));
228230
}

src/components/StartView.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default class StartView extends View {
148148
h('a', { href: 'https://github.com/01397/clouddia' }, 'GitHub'),
149149
]),
150150
h('p', { class: 'start-readme-paragraph' }, [
151-
document.createTextNode('バージョン: v' + this.app.version + ' '),
151+
document.createTextNode('バージョン: ' + this.app.version + ' '),
152152
h(
153153
'a',
154154
{

src/vite-env.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference types="vite/client" />
2+
3+
interface ImportMetaEnv {
4+
// VITE_APP_VERSIONは、GitHub Actionsによるビルド時にGit tagから取得したバージョン番号を設定する
5+
// 例: "v0.1.0"
6+
VITE_APP_VERSION: string;
7+
}
8+
9+
interface ImportMeta {
10+
readonly env: ImportMetaEnv;
11+
}

0 commit comments

Comments
 (0)