chore: more changes and improvements around tunarr versioning

This commit is contained in:
Christian Benincasa
2026-01-05 20:47:50 -05:00
parent cdabbc3c23
commit 22e1467c40
10 changed files with 31 additions and 36 deletions

View File

@@ -7,8 +7,8 @@ on:
push: push:
tags: tags:
- v[0-9]+.[0-9]+.[0-9]+* - v[0-9]+.[0-9]+.[0-9]+*
schedule: # schedule:
- cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime # - cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime
jobs: jobs:
typecheck: typecheck:
@@ -120,7 +120,8 @@ jobs:
- name: Generate Version Number - name: Generate Version Number
run: | run: |
echo "TUNARR_VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV echo "TUNARR_VERSION=${{github.ref_name}}" >> $GITHUB_ENV
echo "TUNARR_BUILD=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Build and push - name: Build and push
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@@ -131,7 +132,8 @@ jobs:
build-args: | build-args: |
base_image_tag=${{ matrix.builds.base_tag }} base_image_tag=${{ matrix.builds.base_tag }}
is_edge_build=${{github.ref == format('refs/heads/{0}', 'dev') && github.event_name == 'schedule'}} is_edge_build=${{github.ref == format('refs/heads/{0}', 'dev') && github.event_name == 'schedule'}}
tunarr_build=${{ env.TUNARR_VERSION }} tunarr_version=${{ env.TUNARR_VERSION }}
tunarr_build=${{ env.TUNARR_BUILD }}
exec_target=${{ matrix.builds.target }} exec_target=${{ matrix.builds.target }}
target: full-stack target: full-stack
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}

View File

@@ -7,8 +7,8 @@ on:
push: push:
tags: tags:
- v[0-9]+.[0-9]+.[0-9]+* - v[0-9]+.[0-9]+.[0-9]+*
schedule: #schedule:
- cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime # - cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime
jobs: jobs:
typecheck: typecheck:
@@ -73,6 +73,7 @@ jobs:
- name: "Create env file" - name: "Create env file"
run: | run: |
touch .env touch .env
echo TUNARR_VERSION="${{github.ref_name}}" >> .env
echo TUNARR_BUILD="$(git rev-parse --short ${{ github.sha }})" >> .env echo TUNARR_BUILD="$(git rev-parse --short ${{ github.sha }})" >> .env
echo TUNARR_EDGE_BUILD=${{github.ref == format('refs/heads/{0}', 'dev') && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')}} >> .env echo TUNARR_EDGE_BUILD=${{github.ref == format('refs/heads/{0}', 'dev') && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')}} >> .env
echo NODE_ENV=production >> .env echo NODE_ENV=production >> .env
@@ -155,7 +156,8 @@ jobs:
echo NODE_ENV=production >> .env echo NODE_ENV=production >> .env
echo TUNARR_BIND_ADDR=0.0.0.0 >> .env echo TUNARR_BIND_ADDR=0.0.0.0 >> .env
tunarr_version="$(jq -r .version package.json)" tunarr_version="${{github.ref_name}}"
tunarr_full_version="${tunarr_version}"
if [[ "$TUNARR_EDGE_BUILD" == "true" || "$TUNARR_EDGE_BUILD" == "1" ]]; then if [[ "$TUNARR_EDGE_BUILD" == "true" || "$TUNARR_EDGE_BUILD" == "1" ]]; then
is_edge_build=true is_edge_build=true
else else
@@ -163,9 +165,10 @@ jobs:
fi fi
if [[ -n "$TUNARR_BUILD" && "$TUNARR_EDGE_BUILD" == true ]]; then if [[ -n "$TUNARR_BUILD" && "$TUNARR_EDGE_BUILD" == true ]]; then
tunarr_version+="-${build}" tunarr_full_version+="-${build}"
fi fi
echo "TUNARR_VERSION=${tunarr_version}" >> .env echo "TUNARR_VERSION=${tunarr_version}" >> .env
echo "TUNARR_FULL_VERSION=${tunarr_full_version}" >> .env
if [[ "$TUNARR_EDGE_BUILD" == true ]]; then if [[ "$TUNARR_EDGE_BUILD" == true ]]; then
release_name="Tunarr-${tunarr_version}-${{ matrix.os.target }}" release_name="Tunarr-${tunarr_version}-${{ matrix.os.target }}"
@@ -189,8 +192,8 @@ jobs:
shell: bash shell: bash
run: | run: |
brew install coreutils brew install coreutils
plutil -replace CFBundleShortVersionString -string "$TUNARR_VERSION" macos/Tunarr/Tunarr/Info.plist plutil -replace CFBundleShortVersionString -string "$TUNARR_FULL_VERSION" macos/Tunarr/Tunarr/Info.plist
plutil -replace CFBundleVersion -string "$TUNARR_VERSION" macos/Tunarr/Tunarr/Info.plist plutil -replace CFBundleVersion -string "$TUNARR_FULL_VERSION" macos/Tunarr/Tunarr/Info.plist
if [[ "$TUNARR_EDGE_BUILD" == "true" || "$TUNARR_EDGE_BUILD" == "1" ]]; then if [[ "$TUNARR_EDGE_BUILD" == "true" || "$TUNARR_EDGE_BUILD" == "1" ]]; then
scripts/bundle-macos.sh "tunarr-${{ matrix.os.target }}" "${{ matrix.os.arch }}" "${{matrix.os.target}}" scripts/bundle-macos.sh "tunarr-${{ matrix.os.target }}" "${{ matrix.os.arch }}" "${{matrix.os.target}}"

View File

@@ -85,11 +85,13 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-l
FROM sources AS build-full-stack FROM sources AS build-full-stack
ARG exec_target=linux-x64 ARG exec_target=linux-x64
ARG is_edge_build ARG is_edge_build
ARG tunarr_version
ARG tunarr_build ARG tunarr_build
ARG exec_target=linux-x64 ARG exec_target=linux-x64
# Build common modules # Build common modules
RUN <<EOF RUN <<EOF
touch .env touch .env
echo TUNARR_VERSION="${tunarr_version}" >> .env
echo TUNARR_BUILD="${tunarr_build}" >> .env echo TUNARR_BUILD="${tunarr_build}" >> .env
echo TUNARR_EDGE_BUILD=${is_edge_build} >> .env echo TUNARR_EDGE_BUILD=${is_edge_build} >> .env
echo TUNARR_BUILD_BASE_TAG=${base_image_tag} >> .env echo TUNARR_BUILD_BASE_TAG=${base_image_tag} >> .env

View File

@@ -74,6 +74,7 @@ const result = await esbuild.build({
metafile: true, metafile: true,
define: { define: {
'process.env.NODE_ENV': '"production"', 'process.env.NODE_ENV': '"production"',
'process.env.TUNARR_VERSION': `"${process.env.TUNARR_VERSION}"`,
'process.env.TUNARR_BUILD': `"${process.env.TUNARR_BUILD}"`, 'process.env.TUNARR_BUILD': `"${process.env.TUNARR_BUILD}"`,
'process.env.TUNARR_EDGE_BUILD': `"${isEdgeBuild}"`, 'process.env.TUNARR_EDGE_BUILD': `"${isEdgeBuild}"`,
'import.meta.url': '__import_meta_url', 'import.meta.url': '__import_meta_url',

View File

@@ -88,6 +88,7 @@ const result = await esbuild.build({
metafile: true, metafile: true,
define: { define: {
'process.env.NODE_ENV': '"production"', 'process.env.NODE_ENV': '"production"',
'process.env.TUNARR_VERSION': `"${process.env.TUNARR_VERSION}"`,
'process.env.TUNARR_BUILD': `"${process.env.TUNARR_BUILD}"`, 'process.env.TUNARR_BUILD': `"${process.env.TUNARR_BUILD}"`,
'process.env.TUNARR_EDGE_BUILD': `"${isEdgeBuild}"`, 'process.env.TUNARR_EDGE_BUILD': `"${isEdgeBuild}"`,
'import.meta.url': '__import_meta_url', 'import.meta.url': '__import_meta_url',

View File

@@ -7,7 +7,8 @@ export const SERVER_PORT_ENV_VAR = 'TUNARR_SERVER_PORT';
export const PRINT_ROUTES_ENV_VAR = 'TUNARR_SERVER_PRINT_ROUTES'; export const PRINT_ROUTES_ENV_VAR = 'TUNARR_SERVER_PRINT_ROUTES';
export const TRUST_PROXY_ENV_VAR = 'TUNARR_SERVER_TRUST_PROXY'; export const TRUST_PROXY_ENV_VAR = 'TUNARR_SERVER_TRUST_PROXY';
export const BIND_ADDR_ENV_VAR = 'TUNARR_BIND_ADDR'; export const BIND_ADDR_ENV_VAR = 'TUNARR_BIND_ADDR';
export const BUILD_ENV_VAR = 'TUNARR_BUILD'; export const BUILD_ENV_VAR = 'TUNARR_VERSION';
export const COMMIT_SHA_ENV_VAR = 'TUNARR_BUILA_SHA';
export const BASE_IMAGE_TAG_ENV_VAR = 'TUNARR_BUILD_BASE_TAG'; export const BASE_IMAGE_TAG_ENV_VAR = 'TUNARR_BUILD_BASE_TAG';
export const IS_EDGE_BUILD_ENV_VAR = 'TUNARR_EDGE_BUILD'; export const IS_EDGE_BUILD_ENV_VAR = 'TUNARR_EDGE_BUILD';
export const USE_WORKER_POOL_ENV_VAR = 'TUNARR_USE_WORKER_POOL'; export const USE_WORKER_POOL_ENV_VAR = 'TUNARR_USE_WORKER_POOL';
@@ -33,6 +34,7 @@ export const TUNARR_ENV_VARS = {
TRUST_PROXY_ENV_VAR, TRUST_PROXY_ENV_VAR,
BIND_ADDR_ENV_VAR, BIND_ADDR_ENV_VAR,
BUILD_ENV_VAR, BUILD_ENV_VAR,
COMMIT_SHA_ENV_VAR,
IS_EDGE_BUILD_ENV_VAR, IS_EDGE_BUILD_ENV_VAR,
BASE_IMAGE_TAG_ENV_VAR, BASE_IMAGE_TAG_ENV_VAR,
USE_WORKER_POOL_ENV_VAR, USE_WORKER_POOL_ENV_VAR,

View File

@@ -34,7 +34,6 @@ import { format, inspect } from 'node:util';
import { isPromise } from 'node:util/types'; import { isPromise } from 'node:util/types';
import type { DeepReadonly, DeepWritable, NonEmptyArray } from 'ts-essentials'; import type { DeepReadonly, DeepWritable, NonEmptyArray } from 'ts-essentials';
import type { NewProgramDao, ProgramDao } from '../db/schema/Program.ts'; import type { NewProgramDao, ProgramDao } from '../db/schema/Program.ts';
import { getBooleanEnvVar, TUNARR_ENV_VARS } from './env.ts';
dayjs.extend(duration); dayjs.extend(duration);
@@ -467,11 +466,6 @@ export const currentEnv = once(() => {
export const isProduction = currentEnv() === 'production'; export const isProduction = currentEnv() === 'production';
export const isDev = currentEnv() === 'development'; export const isDev = currentEnv() === 'development';
export const isTest = currentEnv() === 'test'; export const isTest = currentEnv() === 'test';
export const isEdgeBuild = getBooleanEnvVar(
TUNARR_ENV_VARS.IS_EDGE_BUILD_ENV_VAR,
false,
);
export const tunarrBuild = process.env.TUNARR_BUILD;
export const zipWithIndex = <T>( export const zipWithIndex = <T>(
seq: readonly T[], seq: readonly T[],

View File

@@ -1,11 +1,6 @@
import tunarrPackage from '../../package.json' with { type: 'json' }; import tunarrPackage from '../../package.json' with { type: 'json' };
import { getEnvVar, TUNARR_ENV_VARS } from './env.ts'; import { getBooleanEnvVar, getEnvVar, TUNARR_ENV_VARS } from './env.ts';
import { import { isNonEmptyString, isProduction } from './index.js';
isEdgeBuild,
isNonEmptyString,
isProduction,
tunarrBuild,
} from './index.js';
let tunarrVersion: string; let tunarrVersion: string;
export const getTunarrVersion = () => { export const getTunarrVersion = () => {
@@ -14,6 +9,12 @@ export const getTunarrVersion = () => {
tunarrVersion = tunarrVersion =
getEnvVar(TUNARR_ENV_VARS.BUILD_ENV_VAR) ?? tunarrPackage.version ?? ''; getEnvVar(TUNARR_ENV_VARS.BUILD_ENV_VAR) ?? tunarrPackage.version ?? '';
const isEdgeBuild = getBooleanEnvVar(
TUNARR_ENV_VARS.IS_EDGE_BUILD_ENV_VAR,
false,
);
const tunarrBuild = getEnvVar(TUNARR_ENV_VARS.COMMIT_SHA_ENV_VAR);
if (isNonEmptyString(tunarrBuild) && isEdgeBuild) { if (isNonEmptyString(tunarrBuild) && isEdgeBuild) {
tunarrVersion += `-${tunarrBuild}`; tunarrVersion += `-${tunarrBuild}`;
} }

View File

@@ -1,11 +0,0 @@
// Duplicated from server - reference these instead.
// export const currentEnv = once(() => {
// const env = process.env['NODE_ENV'];
// return env ?? 'production';
// });
// export const isProduction = currentEnv() === 'production';
// export const isDev = currentEnv() === 'development';
// export const isTest = currentEnv() === 'test';
// export const isEdgeBuild = process.env['TUNARR_EDGE_BUILD'] === 'true';
// export const tunarrBuild = process.env['TUNARR_BUILD'];

View File

@@ -13,7 +13,7 @@ export const IS_EDGE_BUILD_ENV_VAR = 'TUNARR_EDGE_BUILD';
const packageVersion = packageDef.version; const packageVersion = packageDef.version;
const version = (() => { const version = (() => {
let tunarrVersion = packageVersion; let tunarrVersion = process.env.TUNARR_VERSION ?? packageVersion;
const build = process.env[BUILD_ENV_VAR] ?? ''; const build = process.env[BUILD_ENV_VAR] ?? '';
const isEdgeBuildValue = process.env[IS_EDGE_BUILD_ENV_VAR]; const isEdgeBuildValue = process.env[IS_EDGE_BUILD_ENV_VAR];
const isEdgeBuild = isEdgeBuildValue === 'true' || isEdgeBuildValue === '1'; const isEdgeBuild = isEdgeBuildValue === 'true' || isEdgeBuildValue === '1';