feat(release): add semantic version to application builds
This commit is contained in:
1 parent
10fd6d8efb
commit
12d13327a6
6 files changed
+22
-3
No files matched your search
+7
-1
@@ -7,12 +7,14 @@ RUN corepack enable && corepack prepare [email protected] --activate
|
||||
COPY web/package.json web/pnpm-lock.yaml web/pnpm-workspace.yaml web/.npmrc ./
|
||||
RUN pnpm install --frozen-lockfile
|
||||
COPY web/ ./
|
||||
COPY VERSION /src/VERSION
|
||||
RUN pnpm build
|
||||
|
||||
# ---- Backend (frontend assets embedded in the binary) ----
|
||||
FROM golang:1-alpine AS server
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
COPY VERSION ./
|
||||
RUN go mod download
|
||||
COPY cmd ./cmd
|
||||
COPY internal ./internal
|
||||
@@ -20,10 +22,14 @@ COPY deploy/embed.go ./deploy/
|
||||
COPY deploy/data/vault ./deploy/data/vault
|
||||
COPY web/embed.go web/font_storage.go ./web/
|
||||
COPY --from=web /src/web/dist ./web/dist
|
||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/rawmark ./cmd/rawmark && mkdir -p /out/data
|
||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.releaseVersion=$(cat VERSION)" -o /out/rawmark ./cmd/rawmark && mkdir -p /out/data
|
||||
|
||||
# ---- Runtime ----
|
||||
FROM gcr.io/distroless/static:nonroot
|
||||
COPY LICENSE /LICENSE
|
||||
COPY web/LICENSE /licenses/vue3-starter-MIT.txt
|
||||
COPY web/src/common/appearance/fonts/*-OFL.txt /licenses/
|
||||
COPY web/src/common/appearance/fonts/maple/LICENSE.txt /licenses/Maple-Mono-OFL.txt
|
||||
COPY --from=server /out/rawmark /rawmark
|
||||
COPY --from=server --chown=nonroot:nonroot /out/data /data
|
||||
ENV RAWMARK_DATA=/data
|
||||
|
||||
@@ -32,6 +32,9 @@ import (
|
||||
"rawmark/web"
|
||||
)
|
||||
|
||||
// releaseVersion is set from VERSION by release and Docker builds.
|
||||
var releaseVersion = "dev"
|
||||
|
||||
func env(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
@@ -40,6 +43,10 @@ func env(key, def string) string {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) > 1 && os.Args[1] == "--version" {
|
||||
fmt.Println("RawMark " + releaseVersion)
|
||||
return
|
||||
}
|
||||
addr := env("RAWMARK_ADDR", ":8080")
|
||||
if len(os.Args) > 1 && os.Args[1] == "healthcheck" {
|
||||
os.Exit(healthcheck(addr))
|
||||
|
||||
@@ -21,6 +21,7 @@ import { searchSettings, SETTINGS_SECTIONS } from './settings-catalog'
|
||||
const props = defineProps<{ prepareMaintenance: () => Promise<void>, restoreNote: (id: string) => Promise<void> }>()
|
||||
const emit = defineEmits<{ importNotes: [] }>()
|
||||
const { settingsSave } = useSettingsStore()
|
||||
const releaseVersion = __RAWMARK_RELEASE__
|
||||
const buildVersion = import.meta.env.DEV ? translate('settings.development_0d1c11') : document.querySelector<HTMLMetaElement>('meta[name="rawmark-version"]')?.content
|
||||
if (!buildVersion) throw new Error(translate('settings.application_build_information_is_missing_6b04f9'))
|
||||
const model = defineModel<SettingsSection | 'index' | null>({ required: true })
|
||||
@@ -80,7 +81,7 @@ function close() {
|
||||
</button>
|
||||
</div>
|
||||
<div class="rm-settings-nav-foot">
|
||||
<span>RawMark</span><small>{{ buildVersion }}</small>
|
||||
<span>RawMark</span><small>{{ releaseVersion }}</small>
|
||||
</div>
|
||||
</nav>
|
||||
<section class="rm-settings-body">
|
||||
@@ -120,7 +121,7 @@ function close() {
|
||||
{{ translate('settings.rawmark_a_markdown_note_editor_66b52a') }}
|
||||
</p>
|
||||
<SettingRow id="version">
|
||||
<code>{{ buildVersion }}</code>
|
||||
<code>{{ releaseVersion }} · {{ buildVersion }}</code>
|
||||
</SettingRow>
|
||||
<SettingRow id="install">
|
||||
<el-button v-if="installPrompt" class="rm-btn" @click="installApp">
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
declare const __RAWMARK_RELEASE__: string
|
||||
@@ -8,7 +8,10 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
const releaseVersion = readFileSync(new URL('../VERSION', import.meta.url), 'utf8').trim()
|
||||
|
||||
export default defineConfig({
|
||||
define: { __RAWMARK_RELEASE__: JSON.stringify(releaseVersion) },
|
||||
resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), '@@': fileURLToPath(new URL('./src/common', import.meta.url)) } },
|
||||
plugins: [
|
||||
vue(),
|
||||
|
||||
Reference in new issue
Block a user