mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 00:53:35 -04:00
chore: more changes and improvements around tunarr versioning
This commit is contained in:
10
.github/workflows/build-and-push-docker.yml
vendored
10
.github/workflows/build-and-push-docker.yml
vendored
@@ -7,8 +7,8 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- v[0-9]+.[0-9]+.[0-9]+*
|
||||
schedule:
|
||||
- cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime
|
||||
# schedule:
|
||||
# - cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime
|
||||
|
||||
jobs:
|
||||
typecheck:
|
||||
@@ -120,7 +120,8 @@ jobs:
|
||||
|
||||
- name: Generate Version Number
|
||||
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
|
||||
uses: docker/build-push-action@v5
|
||||
@@ -131,7 +132,8 @@ jobs:
|
||||
build-args: |
|
||||
base_image_tag=${{ matrix.builds.base_tag }}
|
||||
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 }}
|
||||
target: full-stack
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
15
.github/workflows/build-and-release-binary.yml
vendored
15
.github/workflows/build-and-release-binary.yml
vendored
@@ -7,8 +7,8 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- v[0-9]+.[0-9]+.[0-9]+*
|
||||
schedule:
|
||||
- cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime
|
||||
#schedule:
|
||||
# - cron: "0 13-21/2 * * *" # every 2 hours during US Eastern daytime
|
||||
|
||||
jobs:
|
||||
typecheck:
|
||||
@@ -73,6 +73,7 @@ jobs:
|
||||
- name: "Create env file"
|
||||
run: |
|
||||
touch .env
|
||||
echo TUNARR_VERSION="${{github.ref_name}}" >> .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 NODE_ENV=production >> .env
|
||||
@@ -155,7 +156,8 @@ jobs:
|
||||
echo NODE_ENV=production >> .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
|
||||
is_edge_build=true
|
||||
else
|
||||
@@ -163,9 +165,10 @@ jobs:
|
||||
fi
|
||||
|
||||
if [[ -n "$TUNARR_BUILD" && "$TUNARR_EDGE_BUILD" == true ]]; then
|
||||
tunarr_version+="-${build}"
|
||||
tunarr_full_version+="-${build}"
|
||||
fi
|
||||
echo "TUNARR_VERSION=${tunarr_version}" >> .env
|
||||
echo "TUNARR_FULL_VERSION=${tunarr_full_version}" >> .env
|
||||
|
||||
if [[ "$TUNARR_EDGE_BUILD" == true ]]; then
|
||||
release_name="Tunarr-${tunarr_version}-${{ matrix.os.target }}"
|
||||
@@ -189,8 +192,8 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
brew install coreutils
|
||||
plutil -replace CFBundleShortVersionString -string "$TUNARR_VERSION" macos/Tunarr/Tunarr/Info.plist
|
||||
plutil -replace CFBundleVersion -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_FULL_VERSION" macos/Tunarr/Tunarr/Info.plist
|
||||
|
||||
if [[ "$TUNARR_EDGE_BUILD" == "true" || "$TUNARR_EDGE_BUILD" == "1" ]]; then
|
||||
scripts/bundle-macos.sh "tunarr-${{ matrix.os.target }}" "${{ matrix.os.arch }}" "${{matrix.os.target}}"
|
||||
|
||||
@@ -85,11 +85,13 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-l
|
||||
FROM sources AS build-full-stack
|
||||
ARG exec_target=linux-x64
|
||||
ARG is_edge_build
|
||||
ARG tunarr_version
|
||||
ARG tunarr_build
|
||||
ARG exec_target=linux-x64
|
||||
# Build common modules
|
||||
RUN <<EOF
|
||||
touch .env
|
||||
echo TUNARR_VERSION="${tunarr_version}" >> .env
|
||||
echo TUNARR_BUILD="${tunarr_build}" >> .env
|
||||
echo TUNARR_EDGE_BUILD=${is_edge_build} >> .env
|
||||
echo TUNARR_BUILD_BASE_TAG=${base_image_tag} >> .env
|
||||
|
||||
@@ -74,6 +74,7 @@ const result = await esbuild.build({
|
||||
metafile: true,
|
||||
define: {
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
'process.env.TUNARR_VERSION': `"${process.env.TUNARR_VERSION}"`,
|
||||
'process.env.TUNARR_BUILD': `"${process.env.TUNARR_BUILD}"`,
|
||||
'process.env.TUNARR_EDGE_BUILD': `"${isEdgeBuild}"`,
|
||||
'import.meta.url': '__import_meta_url',
|
||||
|
||||
@@ -88,6 +88,7 @@ const result = await esbuild.build({
|
||||
metafile: true,
|
||||
define: {
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
'process.env.TUNARR_VERSION': `"${process.env.TUNARR_VERSION}"`,
|
||||
'process.env.TUNARR_BUILD': `"${process.env.TUNARR_BUILD}"`,
|
||||
'process.env.TUNARR_EDGE_BUILD': `"${isEdgeBuild}"`,
|
||||
'import.meta.url': '__import_meta_url',
|
||||
|
||||
@@ -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 TRUST_PROXY_ENV_VAR = 'TUNARR_SERVER_TRUST_PROXY';
|
||||
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 IS_EDGE_BUILD_ENV_VAR = 'TUNARR_EDGE_BUILD';
|
||||
export const USE_WORKER_POOL_ENV_VAR = 'TUNARR_USE_WORKER_POOL';
|
||||
@@ -33,6 +34,7 @@ export const TUNARR_ENV_VARS = {
|
||||
TRUST_PROXY_ENV_VAR,
|
||||
BIND_ADDR_ENV_VAR,
|
||||
BUILD_ENV_VAR,
|
||||
COMMIT_SHA_ENV_VAR,
|
||||
IS_EDGE_BUILD_ENV_VAR,
|
||||
BASE_IMAGE_TAG_ENV_VAR,
|
||||
USE_WORKER_POOL_ENV_VAR,
|
||||
|
||||
@@ -34,7 +34,6 @@ import { format, inspect } from 'node:util';
|
||||
import { isPromise } from 'node:util/types';
|
||||
import type { DeepReadonly, DeepWritable, NonEmptyArray } from 'ts-essentials';
|
||||
import type { NewProgramDao, ProgramDao } from '../db/schema/Program.ts';
|
||||
import { getBooleanEnvVar, TUNARR_ENV_VARS } from './env.ts';
|
||||
|
||||
dayjs.extend(duration);
|
||||
|
||||
@@ -467,11 +466,6 @@ export const currentEnv = once(() => {
|
||||
export const isProduction = currentEnv() === 'production';
|
||||
export const isDev = currentEnv() === 'development';
|
||||
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>(
|
||||
seq: readonly T[],
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import tunarrPackage from '../../package.json' with { type: 'json' };
|
||||
import { getEnvVar, TUNARR_ENV_VARS } from './env.ts';
|
||||
import {
|
||||
isEdgeBuild,
|
||||
isNonEmptyString,
|
||||
isProduction,
|
||||
tunarrBuild,
|
||||
} from './index.js';
|
||||
import { getBooleanEnvVar, getEnvVar, TUNARR_ENV_VARS } from './env.ts';
|
||||
import { isNonEmptyString, isProduction } from './index.js';
|
||||
|
||||
let tunarrVersion: string;
|
||||
export const getTunarrVersion = () => {
|
||||
@@ -14,6 +9,12 @@ export const getTunarrVersion = () => {
|
||||
tunarrVersion =
|
||||
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) {
|
||||
tunarrVersion += `-${tunarrBuild}`;
|
||||
}
|
||||
|
||||
@@ -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'];
|
||||
@@ -13,7 +13,7 @@ export const IS_EDGE_BUILD_ENV_VAR = 'TUNARR_EDGE_BUILD';
|
||||
const packageVersion = packageDef.version;
|
||||
|
||||
const version = (() => {
|
||||
let tunarrVersion = packageVersion;
|
||||
let tunarrVersion = process.env.TUNARR_VERSION ?? packageVersion;
|
||||
const build = process.env[BUILD_ENV_VAR] ?? '';
|
||||
const isEdgeBuildValue = process.env[IS_EDGE_BUILD_ENV_VAR];
|
||||
const isEdgeBuild = isEdgeBuildValue === 'true' || isEdgeBuildValue === '1';
|
||||
|
||||
Reference in New Issue
Block a user