diff --git a/.github/workflows/hidrive-next-build.yml b/.github/workflows/hidrive-next-build.yml index dfa0cf7443049..4003a91762670 100644 --- a/.github/workflows/hidrive-next-build.yml +++ b/.github/workflows/hidrive-next-build.yml @@ -120,6 +120,15 @@ jobs: - name: Add config partials run: make -f IONOS/Makefile add_config_partials + # IONOS Customization: Inject build number for production traceability + # This is specific to IONOS HiDrive Next and not part of upstream Nextcloud + - name: Inject build number + run: | + echo "${{ github.run_number }}" > .buildnumber + echo "✅ Build number injected: ${{ github.run_number }}" + echo "📄 File created: .buildnumber" + cat .buildnumber + - name: Zip dependencies run: make -f IONOS/Makefile zip_dependencies TARGET_PACKAGE_NAME=${{ env.TARGET_PACKAGE_NAME }} diff --git a/.gitignore b/.gitignore index db05c7794b98e..400a0d0141633 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,9 @@ /translationfiles /translationtool.phar +# CI/CD generated files +/.buildnumber + # ignore all apps except core ones /apps*/* !/apps/cloud_federation_api diff --git a/version.php b/version.php index 0cce4c8340e43..a6c560befc230 100644 --- a/version.php +++ b/version.php @@ -32,3 +32,51 @@ // Vendor of this package $vendor = 'nextcloud'; + +// ============================================================================ +// CI/CD Build Number Injection (IONOS Nextcloud Workspace) +// ============================================================================ +// Injects a 5th element into the $OC_Version array from the .buildnumber file. +// This file is automatically created by the CI/CD pipeline (build-artifact.yml) +// and contains the GitHub workflow run ID for traceability. +// +// NOTE: This is an IONOS-specific customization for Nextcloud Workspace. +// It is not part of upstream Nextcloud and is used for tracking +// IONOS Nextcloud Workspace builds in production environments. +// +// @since 31.0.8 +// +// Purpose: +// - Track which specific CI/CD run produced this artifact +// - Enable direct linking to workflow logs and build details +// - Distinguish between different builds of the same version +// - Support debugging by identifying exact build in production +// +// File Format: +// .buildnumber - Single line containing an integer (GitHub run ID) +// Example: 12345678901 +// +// Result: +// Without .buildnumber: $OC_Version = [31, 0, 8, 1] +// With .buildnumber: $OC_Version = [31, 0, 8, 1, 12345678901] +// +// Accessed via: +// - ServerVersion::getBuildId() -> 12345678901 +// - ServerVersion::getHumanVersion() -> "31.0.8 (12345678901)" +// - ServerVersion::getVersion() -> [31, 0, 8, 1, 12345678901] +// +// Workflow URL Construction: +// https://github.com/{org}/{repo}/actions/runs/{buildId} +// +// ============================================================================ +$buildNumberFile = __DIR__ . '/.buildnumber'; +if (file_exists($buildNumberFile)) { + $buildNumberContent = @file_get_contents($buildNumberFile); + if ($buildNumberContent !== false) { + $buildId = (int)trim($buildNumberContent); + if ($buildId > 0) { + // Append build ID as 5th element in version array + $OC_Version[] = $buildId; + } + } +}