From 443d08381ab27315d714e50278f90966d6693ca7 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen <jrasm91@gmail.com> Date: Mon, 23 Jan 2023 22:46:37 -0500 Subject: [PATCH] build: version pump script (#1398) * build: version pump script * feat: server pump is optional * chore: remove unused variable * chore: examples Co-authored-by: Alex <alex.tran1502@gmail.com> --- .../providers/server_info.provider.dart | 1 - mobile/openapi/doc/AssetApi.md | 2 +- mobile/openapi/doc/ServerVersionReponseDto.md | 1 - mobile/openapi/lib/api/asset_api.dart | 4 +- .../lib/model/server_version_reponse_dto.dart | 14 +--- mobile/openapi/test/asset_api_test.dart | 2 +- .../test/server_version_reponse_dto_test.dart | 5 -- scripts/pump-version.sh | 67 +++++++++++++++++++ .../server-version-response.dto.ts | 2 - .../src/constants/server_version.constant.ts | 13 ++-- server/immich-openapi-specs.json | 6 +- server/package-lock.json | 4 +- server/package.json | 2 +- web/src/api/open-api/api.ts | 14 ++-- 14 files changed, 88 insertions(+), 49 deletions(-) create mode 100755 scripts/pump-version.sh diff --git a/mobile/lib/shared/providers/server_info.provider.dart b/mobile/lib/shared/providers/server_info.provider.dart index 0794e73cd3..f7e68fa9c2 100644 --- a/mobile/lib/shared/providers/server_info.provider.dart +++ b/mobile/lib/shared/providers/server_info.provider.dart @@ -13,7 +13,6 @@ class ServerInfoNotifier extends StateNotifier<ServerInfoState> { major: 0, patch_: 0, minor: 0, - build: 0, ), isVersionMismatch: false, versionMismatchErrorMessage: "", diff --git a/mobile/openapi/doc/AssetApi.md b/mobile/openapi/doc/AssetApi.md index 5470053533..ec44259aac 100644 --- a/mobile/openapi/doc/AssetApi.md +++ b/mobile/openapi/doc/AssetApi.md @@ -336,7 +336,7 @@ Name | Type | Description | Notes - +Current this is not used in any UI element ### Example ```dart diff --git a/mobile/openapi/doc/ServerVersionReponseDto.md b/mobile/openapi/doc/ServerVersionReponseDto.md index e40920e506..68dfa972cc 100644 --- a/mobile/openapi/doc/ServerVersionReponseDto.md +++ b/mobile/openapi/doc/ServerVersionReponseDto.md @@ -11,7 +11,6 @@ Name | Type | Description | Notes **major** | **int** | | **minor** | **int** | | **patch_** | **int** | | -**build** | **int** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/mobile/openapi/lib/api/asset_api.dart b/mobile/openapi/lib/api/asset_api.dart index 5f4f278d2b..bf74816735 100644 --- a/mobile/openapi/lib/api/asset_api.dart +++ b/mobile/openapi/lib/api/asset_api.dart @@ -347,7 +347,7 @@ class AssetApi { return null; } - /// + /// Current this is not used in any UI element /// /// Note: This method returns the HTTP [Response]. /// @@ -383,7 +383,7 @@ class AssetApi { ); } - /// + /// Current this is not used in any UI element /// /// Parameters: /// diff --git a/mobile/openapi/lib/model/server_version_reponse_dto.dart b/mobile/openapi/lib/model/server_version_reponse_dto.dart index aec917e275..361a1c6486 100644 --- a/mobile/openapi/lib/model/server_version_reponse_dto.dart +++ b/mobile/openapi/lib/model/server_version_reponse_dto.dart @@ -16,7 +16,6 @@ class ServerVersionReponseDto { required this.major, required this.minor, required this.patch_, - required this.build, }); int major; @@ -25,32 +24,27 @@ class ServerVersionReponseDto { int patch_; - int build; - @override bool operator ==(Object other) => identical(this, other) || other is ServerVersionReponseDto && other.major == major && other.minor == minor && - other.patch_ == patch_ && - other.build == build; + other.patch_ == patch_; @override int get hashCode => // ignore: unnecessary_parenthesis (major.hashCode) + (minor.hashCode) + - (patch_.hashCode) + - (build.hashCode); + (patch_.hashCode); @override - String toString() => 'ServerVersionReponseDto[major=$major, minor=$minor, patch_=$patch_, build=$build]'; + String toString() => 'ServerVersionReponseDto[major=$major, minor=$minor, patch_=$patch_]'; Map<String, dynamic> toJson() { final json = <String, dynamic>{}; json[r'major'] = this.major; json[r'minor'] = this.minor; json[r'patch'] = this.patch_; - json[r'build'] = this.build; return json; } @@ -76,7 +70,6 @@ class ServerVersionReponseDto { major: mapValueOfType<int>(json, r'major')!, minor: mapValueOfType<int>(json, r'minor')!, patch_: mapValueOfType<int>(json, r'patch')!, - build: mapValueOfType<int>(json, r'build')!, ); } return null; @@ -129,7 +122,6 @@ class ServerVersionReponseDto { 'major', 'minor', 'patch', - 'build', }; } diff --git a/mobile/openapi/test/asset_api_test.dart b/mobile/openapi/test/asset_api_test.dart index 930893b394..fa5c0a9bdb 100644 --- a/mobile/openapi/test/asset_api_test.dart +++ b/mobile/openapi/test/asset_api_test.dart @@ -59,7 +59,7 @@ void main() { // TODO }); - // + // Current this is not used in any UI element // //Future<Object> downloadLibrary({ num skip }) async test('test downloadLibrary', () async { diff --git a/mobile/openapi/test/server_version_reponse_dto_test.dart b/mobile/openapi/test/server_version_reponse_dto_test.dart index f09efec332..3095e7a462 100644 --- a/mobile/openapi/test/server_version_reponse_dto_test.dart +++ b/mobile/openapi/test/server_version_reponse_dto_test.dart @@ -31,11 +31,6 @@ void main() { // TODO }); - // int build - test('to test the property `build`', () async { - // TODO - }); - }); diff --git a/scripts/pump-version.sh b/scripts/pump-version.sh new file mode 100755 index 0000000000..dc09ad42f1 --- /dev/null +++ b/scripts/pump-version.sh @@ -0,0 +1,67 @@ +#/bin/bash + +# +# Pump one or both of the server/mobile versions in appropriate files +# +# usage: './scripts/pump-version.sh <major|minor|patch|fase> <mobile|false'> +# +# examples: +# ./scripts/pump-version.sh major false # 1.0.0+50 => 2.0.0+50 +# ./scripts/pump-version.sh minor mobile # 1.0.0+50 => 1.1.0+51 +# ./scripts/pump-version.sh false mobile # 1.0.0+50 => 1.0.0+51 +# + +SERVER_PUMP=$1 +MOBILE_PUMP=$2 + +CURRENT_SERVER=$(cat server/package.json | jq -r '.version') +MAJOR=$(echo $CURRENT_SERVER | cut -d '.' -f1) +MINOR=$(echo $CURRENT_SERVER | cut -d '.' -f2) +PATCH=$(echo $CURRENT_SERVER | cut -d '.' -f3) + +if [[ $SERVER_PUMP == "major" ]]; then + MAJOR=$((MAJOR + 1)) +elif [[ $SERVER_PUMP == "minor" ]]; then + MINOR=$((MINOR + 1)) +elif [[ $1 == "patch" ]]; then + PATCH=$((PATCH + 1)) +elif [[ $SERVER_PUMP == "false" ]]; then + echo 'Skipping Server Pump' +else + echo 'Expected <major|minor|patch|false> for the first argument' + exit 1 +fi + +NEXT_SERVER=$MAJOR.$MINOR.$PATCH + +CURRENT_MOBILE=$(cat mobile/pubspec.yaml | grep "^version: .*+[0-9]\+$" | cut -d "+" -f2) +NEXT_MOBILE=$CURRENT_MOBILE +if [[ $MOBILE_PUMP == "mobile" ]]; then + set $((NEXT_MOBILE++)) +elif [[ $MOBILE_PUMP == "false" ]]; then + echo 'Skipping Mobile Pump' +else + echo 'Expected <mobile|false> for the second argument' + exit 1 +fi + + + +if [ "$CURRENT_SERVER" != "$NEXT_SERVER" ]; then + + echo "Pumping Server: $CURRENT_SERVER => $NEXT_SERVER" + + sed -i "s/^ \"version\": \"$CURRENT_SERVER\",$/ \"version\": \"$NEXT_SERVER\",/" server/package.json + sed -i "s/^ \"version\": \"$CURRENT_SERVER\",$/ \"version\": \"$NEXT_SERVER\",/" server/package-lock.json + sed -i "s/\"android\.injected\.version\.name\" => \"$CURRENT_SERVER\",/\"android\.injected\.version\.name\" => \"$NEXT_SERVER\",/" mobile/android/fastlane/Fastfile +fi + + + +if [ "$CURRENT_MOBILE" != "$NEXT_MOBILE" ]; then + + echo "Pumping Mobile: $CURRENT_MOBILE => $NEXT_MOBILE" + + sed -i "s/\"android\.injected\.version\.code\" => $CURRENT_MOBILE,/\"android\.injected\.version\.code\" => $NEXT_MOBILE,/" mobile/android/fastlane/Fastfile + sed -i "s/^version: $CURRENT_SERVER+$CURRENT_MOBILE$/version: $NEXT_SERVER+$NEXT_MOBILE/" mobile/pubspec.yaml +fi diff --git a/server/apps/immich/src/api-v1/server-info/response-dto/server-version-response.dto.ts b/server/apps/immich/src/api-v1/server-info/response-dto/server-version-response.dto.ts index 812f3b0714..38d1a74e18 100644 --- a/server/apps/immich/src/api-v1/server-info/response-dto/server-version-response.dto.ts +++ b/server/apps/immich/src/api-v1/server-info/response-dto/server-version-response.dto.ts @@ -8,6 +8,4 @@ export class ServerVersionReponseDto implements IServerVersion { minor!: number; @ApiProperty({ type: 'integer' }) patch!: number; - @ApiProperty({ type: 'integer' }) - build!: number; } diff --git a/server/apps/immich/src/constants/server_version.constant.ts b/server/apps/immich/src/constants/server_version.constant.ts index 6f606bd768..9dc0f5e1b2 100644 --- a/server/apps/immich/src/constants/server_version.constant.ts +++ b/server/apps/immich/src/constants/server_version.constant.ts @@ -1,18 +1,17 @@ -// major.minor.patch+build -// check mobile/pubspec.yml for current release version +import pkg from 'package.json'; + +const [major, minor, patch] = pkg.version.split('.'); export interface IServerVersion { major: number; minor: number; patch: number; - build: number; } export const serverVersion: IServerVersion = { - major: 1, - minor: 42, - patch: 0, - build: 65, + major: Number(major), + minor: Number(minor), + patch: Number(patch), }; export const SERVER_VERSION = `${serverVersion.major}.${serverVersion.minor}.${serverVersion.patch}`; diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json index c2df710b75..1be130bf9d 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -4448,16 +4448,12 @@ }, "patch": { "type": "integer" - }, - "build": { - "type": "integer" } }, "required": [ "major", "minor", - "patch", - "build" + "patch" ] }, "UsageByUserDto": { diff --git a/server/package-lock.json b/server/package-lock.json index 0d93ea1da8..500c72d19c 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,12 +1,12 @@ { "name": "immich", - "version": "1.5.1", + "version": "1.42.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "immich", - "version": "1.5.1", + "version": "1.42.0", "license": "UNLICENSED", "dependencies": { "@nestjs/bull": "^0.6.2", diff --git a/server/package.json b/server/package.json index 578f4adc77..490526d7a3 100644 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "immich", - "version": "1.5.1", + "version": "1.42.0", "description": "", "author": "", "private": true, diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index fbf72b2465..27ca348332 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -1575,12 +1575,6 @@ export interface ServerVersionReponseDto { * @memberof ServerVersionReponseDto */ 'patch': number; - /** - * - * @type {number} - * @memberof ServerVersionReponseDto - */ - 'build': number; } /** * @@ -3813,7 +3807,7 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration }; }, /** - * + * Current this is not used in any UI element * @param {number} [skip] * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -4499,7 +4493,7 @@ export const AssetApiFp = function(configuration?: Configuration) { return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** - * + * Current this is not used in any UI element * @param {number} [skip] * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -4725,7 +4719,7 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath return localVarFp.downloadFiles(downloadFilesDto, options).then((request) => request(axios, basePath)); }, /** - * + * Current this is not used in any UI element * @param {number} [skip] * @param {*} [options] Override http request option. * @throws {RequiredError} @@ -4947,7 +4941,7 @@ export class AssetApi extends BaseAPI { } /** - * + * Current this is not used in any UI element * @param {number} [skip] * @param {*} [options] Override http request option. * @throws {RequiredError}