diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0832616985599aa6abcdd631224d231ee447a913..cfdd118792cba2f1c05111472515750fd67926a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,108 @@ +default: + interruptible: true + before_script: + - 'echo "Running on $(uname -a)"' + +.rules_default: &rules_default + rules: + - if: '$CI_COMMIT_TAG' + - if: '$CI_COMMIT_BRANCH' + +.extract_version: &extract_version + - | + set -euo pipefail + echo "Deriving package version from appinfo/info.xml ..." + RAW_VERSION=$(xmllint --xpath 'string(/info/version)' appinfo/info.xml 2>/dev/null || true) + if [ -z "${RAW_VERSION:-}" ]; then + RAW_VERSION=$(php -r '$x=@simplexml_load_file("appinfo/info.xml"); if(!$x||empty($x->version)){exit(1);} echo $x->version, PHP_EOL;' 2>/dev/null || true) + fi + if [ -z "${RAW_VERSION:-}" ]; then + echo "Could not extract version from appinfo/info.xml" >&2 + exit 1 + fi + RAW_VERSION=${RAW_VERSION#v} + if [ -n "${CI_COMMIT_TAG:-}" ]; then + PACKAGE_VERSION="${CI_COMMIT_TAG#v}" + else + # Append short SHA to make version unique for non-tag builds + PACKAGE_VERSION="${RAW_VERSION}-${CI_COMMIT_SHORT_SHA}" + fi + echo "PACKAGE_VERSION=${PACKAGE_VERSION}" | tee -a version.env + +variables: + NODE_ENV: production + npm_config_ci: 'true' + +cache: + paths: + - .npm/ + - vendor/cache/ + +build:vendor: + stage: build + image: composer:2 + needs: [] + <<: *rules_default + before_script: + - composer --version + - php -v + script: + - *extract_version + - composer install --no-dev --prefer-dist --no-progress --optimize-autoloader --classmap-authoritative + - tar -czf vendor.tar.gz vendor + artifacts: + name: "vendor-$CI_COMMIT_REF_SLUG" + paths: + - vendor.tar.gz + - version.env + expire_in: 7 days + +build:frontend: + stage: build + image: node:16-bullseye + needs: [] + <<: *rules_default + before_script: + - node -v + - npm -v + script: + - *extract_version + - npm ci --cache .npm --prefer-offline + - npm run build + - tar -czf assets.tar.gz js css + artifacts: + name: "assets-$CI_COMMIT_REF_SLUG" + paths: + - assets.tar.gz + - version.env + expire_in: 7 days + +publish:generic-registry: + stage: deploy + image: curlimages/curl:8.10.1 + needs: + - job: build:vendor + artifacts: true + - job: build:frontend + artifacts: true + <<: *rules_default + script: + - | + set -euo pipefail + source version.env + echo "Publishing vendor and assets to Generic Package Registry (version: $PACKAGE_VERSION)" + BASE_URL="$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic" + VENDOR_PKG_NAME="ecloud-accounts-vendor" + ASSETS_PKG_NAME="ecloud-accounts-assets" + echo "Uploading vendor.tar.gz ..." + curl --fail --show-error --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file vendor.tar.gz "$BASE_URL/$VENDOR_PKG_NAME/$PACKAGE_VERSION/vendor.tar.gz" + echo "Uploading assets.tar.gz ..." + curl --fail --show-error --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file assets.tar.gz "$BASE_URL/$ASSETS_PKG_NAME/$PACKAGE_VERSION/assets.tar.gz" + artifacts: + when: always + reports: + dotenv: version.env + stages: - test - build diff --git a/appinfo/info.xml b/appinfo/info.xml index d54d53e40af32de4265b95d223752dcfc296fc24..0667b9fcd40d3a10e8ebf03c2183ad2f98ee54cc 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -10,7 +10,7 @@ - 12.0.1 + v12.0.1 agpl Murena SAS EcloudAccounts