From e226903a1fbb9b5dd2098cc6d13a1cdacc1f214e Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 12:49:53 +0100 Subject: [PATCH 01/18] task: Test first GHA workflow [DHIS2-18615] --- .github/workflows/hello-world.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/hello-world.yml diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml new file mode 100644 index 000000000000..817ffe37fe62 --- /dev/null +++ b/.github/workflows/hello-world.yml @@ -0,0 +1,18 @@ +name: Hello World Pipeline + +on: [ pull_request ] + +jobs: + say-hello: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Print Hello World + run: echo "Hello, World!" From 3731bab38f8553559e47220614dc7b9fd1e26f5d Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 13:08:35 +0100 Subject: [PATCH 02/18] task: Run it after check formatting workflow [DHIS2-18615] --- .github/workflows/hello-world.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 817ffe37fe62..5cdaa6e190bf 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -1,6 +1,11 @@ name: Hello World Pipeline -on: [ pull_request ] +on: + workflow_run: + workflows: ["Check formatting"] + types: + - completed + pull_request: jobs: say-hello: From 89254127bd537c214b3d943b98ac9d02dc808bbd Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 14:45:05 +0100 Subject: [PATCH 03/18] task: Disable other workflows [DHIS2-18615] --- .github/workflows/analyse-pr.yml | 11 +---------- .github/workflows/check-formatting.yml | 3 ++- .github/workflows/codeql-analysis.yml | 4 +--- .github/workflows/dependabot.yml | 2 +- .github/workflows/deploy-instance.yml | 3 +-- .github/workflows/destroy-instance.yml | 3 +-- .github/workflows/run-api-analytics-tests.yml | 3 +-- .github/workflows/run-api-tests.yml | 5 +---- .github/workflows/run-tests.yml | 5 +---- 9 files changed, 10 insertions(+), 29 deletions(-) diff --git a/.github/workflows/analyse-pr.yml b/.github/workflows/analyse-pr.yml index 1904681dcddc..be5b0cfd7c02 100644 --- a/.github/workflows/analyse-pr.yml +++ b/.github/workflows/analyse-pr.yml @@ -5,16 +5,7 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.DHIS2_BOT_SONARCLOUD_TOKEN }} on: - push: - branches: - - master - - "2.3[1-9]" - - "2.4[0-9]" - pull_request: - branches: - - master - - "2.3[1-9]" - - "2.4[0-9]" + workflow_dispatch: # Only manual trigger, no automatic triggers concurrency: group: ${{ github.workflow}}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml index 2b5160a7641c..ceff9d497a4a 100644 --- a/.github/workflows/check-formatting.yml +++ b/.github/workflows/check-formatting.yml @@ -3,7 +3,8 @@ env: # This is to make sure Maven don't timeout fetching dependencies. See: https://github.com/actions/virtual-environments/issues/1499 MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125 -on: [ pull_request ] +on: + workflow_dispatch: # Only manual trigger, no automatic triggers jobs: check-formatting: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4a773b03c8cf..74ed72de4bfd 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,9 +9,7 @@ env: MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125 on: - pull_request: - branches: - - master + workflow_dispatch: # Only manual trigger, no automatic triggers schedule: - cron: "0 12 * * *" concurrency: diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 686e56efa7de..91853fd7b8cb 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -1,7 +1,7 @@ name: Dependabot auto-merge on: - pull_request: + workflow_dispatch: # Only manual trigger, no automatic triggers permissions: pull-requests: write diff --git a/.github/workflows/deploy-instance.yml b/.github/workflows/deploy-instance.yml index b98eee3d18fc..a6c292ebbbc9 100644 --- a/.github/workflows/deploy-instance.yml +++ b/.github/workflows/deploy-instance.yml @@ -1,8 +1,7 @@ name: Deploy instance on: - pull_request: - types: [opened, reopened, labeled, synchronize] + workflow_dispatch: # Only manual trigger, no automatic triggers # Cancel previous runs of the same workflow and PR number or branch/tag concurrency: diff --git a/.github/workflows/destroy-instance.yml b/.github/workflows/destroy-instance.yml index 8aed59617645..bae6d9f0433b 100644 --- a/.github/workflows/destroy-instance.yml +++ b/.github/workflows/destroy-instance.yml @@ -1,8 +1,7 @@ name: Destroy instance on: - pull_request: - types: [closed, unlabeled] + workflow_dispatch: # Only manual trigger, no automatic triggers # Cancel previous runs of the same workflow and PR number or branch/tag concurrency: diff --git a/.github/workflows/run-api-analytics-tests.yml b/.github/workflows/run-api-analytics-tests.yml index d6887243e769..3313075ac254 100644 --- a/.github/workflows/run-api-analytics-tests.yml +++ b/.github/workflows/run-api-analytics-tests.yml @@ -4,8 +4,7 @@ env: MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125 on: - pull_request: - types: [opened, labeled, synchronize] + workflow_dispatch: # Only manual trigger, no automatic triggers schedule: - cron: "16 1 * * *" # Run at 01:16 AM concurrency: diff --git a/.github/workflows/run-api-tests.yml b/.github/workflows/run-api-tests.yml index c244585a27f2..0bcb848ef36b 100644 --- a/.github/workflows/run-api-tests.yml +++ b/.github/workflows/run-api-tests.yml @@ -4,10 +4,7 @@ env: MAVEN_OPTS: -Xmx1024m -Xms1024m -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125 on: - push: - branches: - - master - pull_request: + workflow_dispatch: # Only manual trigger, no automatic triggers concurrency: group: ${{ github.workflow}}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4226b4bb46e0..99cc58bd7121 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -3,10 +3,7 @@ env: # This is to make sure Maven don't timeout fetching dependencies. See: https://github.com/actions/virtual-environments/issues/1499 MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125 on: - push: - branches: - - master - pull_request: + workflow_dispatch: # Only manual trigger, no automatic triggers concurrency: group: ${{ github.workflow}}-${{ github.ref }} cancel-in-progress: true From dae7660b1c21ef8088ca034a0c5a98aa4ec62be8 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 14:45:51 +0100 Subject: [PATCH 04/18] task: Trigger maven buid [DHIS2-18615] --- .github/workflows/hello-world.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 5cdaa6e190bf..bd2dae04053a 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -1,11 +1,13 @@ name: Hello World Pipeline on: - workflow_run: - workflows: ["Check formatting"] - types: - - completed pull_request: +# For this to work, this workflow needs to be on master https://github.com/orgs/community/discussions/66512#discussioncomment-6950485 +# workflow_run: +# workflows: ["Check formatting"] +# types: +# - completed + jobs: say-hello: @@ -21,3 +23,11 @@ jobs: - name: Print Hello World run: echo "Hello, World!" + + # Set up Maven + - name: Set up Maven + run: sudo apt-get install maven + + # Run Maven build + - name: Build with Maven + run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --file From 4bd4e58c82263977ba52085a5fc9302ad34fdaa0 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 14:47:27 +0100 Subject: [PATCH 05/18] task: Trigger maven buid [DHIS2-18615] --- .github/workflows/hello-world.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index bd2dae04053a..4c599996ec9b 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -30,4 +30,4 @@ jobs: # Run Maven build - name: Build with Maven - run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --file + run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --file dhis-2/pom.xml --update-snapshots From e9b49692cf73bca8e8db4ef158d1fa423e045b8b Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 14:48:35 +0100 Subject: [PATCH 06/18] task: Trigger maven buid [DHIS2-18615] --- .github/workflows/hello-world.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 4c599996ec9b..79b8839a9736 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -30,4 +30,4 @@ jobs: # Run Maven build - name: Build with Maven - run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --file dhis-2/pom.xml --update-snapshots + run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --update-snapshots --file ./dhis-2/pom.xml From 53960f7024aac730a93734eefb606abe91d38810 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 15:10:53 +0100 Subject: [PATCH 07/18] task: Skip tests [DHIS2-18615] --- .github/workflows/hello-world.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 79b8839a9736..ecaa9d14910a 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -30,4 +30,4 @@ jobs: # Run Maven build - name: Build with Maven - run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --update-snapshots --file ./dhis-2/pom.xml + run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --update-snapshots --file ./dhis-2/pom.xml -DskipTests From 28ade02d7c4307b6cd0af3832669e03358c3b40a Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 15:24:35 +0100 Subject: [PATCH 08/18] task: Skip tests [DHIS2-18615] --- .github/workflows/hello-world.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index ecaa9d14910a..17688d79ae31 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -21,9 +21,6 @@ jobs: java-version: 17 distribution: temurin - - name: Print Hello World - run: echo "Hello, World!" - # Set up Maven - name: Set up Maven run: sudo apt-get install maven From dfa6406795bc8d0a9a20947b0554f52f66b8374c Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 16:03:50 +0100 Subject: [PATCH 09/18] Upload to S3 --- .github/workflows/hello-world.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 17688d79ae31..356202135c1d 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -2,13 +2,12 @@ name: Hello World Pipeline on: pull_request: -# For this to work, this workflow needs to be on master https://github.com/orgs/community/discussions/66512#discussioncomment-6950485 +# For this to work, this workflow needs to be on master https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_run # workflow_run: # workflows: ["Check formatting"] # types: # - completed - jobs: say-hello: runs-on: ubuntu-latest @@ -28,3 +27,10 @@ jobs: # Run Maven build - name: Build with Maven run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --update-snapshots --file ./dhis-2/pom.xml -DskipTests + + - name: Sync war + run: | + echo 'Syncing WAR for $GITHUB_REF_NAME' + curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O + chmod +x copy-war-s3.sh + ./copy-war-s3.sh dev $GITHUB_REF_NAME \ No newline at end of file From 085f5dc790c91cc25e71ceca4c9bba34a603eb90 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 16:13:24 +0100 Subject: [PATCH 10/18] Print branch and commit --- .github/workflows/hello-world.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 356202135c1d..e1c244c12421 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -22,7 +22,10 @@ jobs: # Set up Maven - name: Set up Maven - run: sudo apt-get install maven + run: | + sudo apt-get install maven + echo "On branch: $GITHUB_REF_NAME" + echo "Git commit: ${{ github.sha }}"" # Run Maven build - name: Build with Maven @@ -30,7 +33,7 @@ jobs: - name: Sync war run: | - echo 'Syncing WAR for $GITHUB_REF_NAME' + echo "Syncing WAR ..." curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O chmod +x copy-war-s3.sh ./copy-war-s3.sh dev $GITHUB_REF_NAME \ No newline at end of file From 9428a2e27ad5a3133f8dc9ec3a188deac1716ac6 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 16:16:15 +0100 Subject: [PATCH 11/18] Print branch and commit --- .github/workflows/hello-world.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index e1c244c12421..25be9cf4c007 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -22,10 +22,12 @@ jobs: # Set up Maven - name: Set up Maven + env: + COMMIT_HASH: ${{ github.sha }} run: | sudo apt-get install maven echo "On branch: $GITHUB_REF_NAME" - echo "Git commit: ${{ github.sha }}"" + echo "Git commit: $COMMIT_HASH" # Run Maven build - name: Build with Maven From 77338e7c18cabc7803c9a1108f3a986fc172f1c1 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 16:20:21 +0100 Subject: [PATCH 12/18] Print branch and commit --- .github/workflows/hello-world.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 25be9cf4c007..5883e68d6754 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -23,11 +23,11 @@ jobs: # Set up Maven - name: Set up Maven env: - COMMIT_HASH: ${{ github.sha }} + GIT_COMMIT: ${{ github.sha }} run: | sudo apt-get install maven - echo "On branch: $GITHUB_REF_NAME" - echo "Git commit: $COMMIT_HASH" + echo "On branch: $GITHUB_HEAD_REF" + echo "Git commit: GIT_COMMIT" # Run Maven build - name: Build with Maven From 923e8c868c403d74e9707b0f002e56bbd86cd901 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 13 Dec 2024 16:27:06 +0100 Subject: [PATCH 13/18] task: Define git commit env variable [DHIS2-18615] --- .github/workflows/hello-world.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 5883e68d6754..d897d002c3df 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -11,6 +11,8 @@ on: jobs: say-hello: runs-on: ubuntu-latest + env: + GIT_COMMIT: ${{ github.sha }} # Declare GIT_COMMIT for the entire job steps: - uses: actions/checkout@v4 @@ -22,12 +24,10 @@ jobs: # Set up Maven - name: Set up Maven - env: - GIT_COMMIT: ${{ github.sha }} run: | sudo apt-get install maven echo "On branch: $GITHUB_HEAD_REF" - echo "Git commit: GIT_COMMIT" + echo "Git commit: $GIT_COMMIT" # Run Maven build - name: Build with Maven @@ -38,4 +38,4 @@ jobs: echo "Syncing WAR ..." curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O chmod +x copy-war-s3.sh - ./copy-war-s3.sh dev $GITHUB_REF_NAME \ No newline at end of file + ./copy-war-s3.sh dev $GITHUB_HEAD_REF \ No newline at end of file From ba685f6b8bc731fe59529f246e9336d2d705c8f1 Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 16 Dec 2024 13:00:21 +0100 Subject: [PATCH 14/18] task: Use self scipt to copy war to S3 [DHIS2-18615] --- .github/workflows/gha-copy-war-s3.sh | 128 ++++++++++++++++++ ...-world.yml => update-instance-manager.yml} | 9 +- 2 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/gha-copy-war-s3.sh rename .github/workflows/{hello-world.yml => update-instance-manager.yml} (81%) diff --git a/.github/workflows/gha-copy-war-s3.sh b/.github/workflows/gha-copy-war-s3.sh new file mode 100644 index 000000000000..7d0846fdac9f --- /dev/null +++ b/.github/workflows/gha-copy-war-s3.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash + +# This script is used in the pipelines for all the supported dhis2-core branches, including +# master and 4 major versions before that and for all the build types - dev, canary, eos and stable. + +set -euo pipefail + +BUILD_DATE=$(date -I'date') + +IS_PATCH_VERSION=0 + +VERSIONS_JSON="https://releases.dhis2.org/v1/versions/stable.json" + +BUCKET="s3://releases.dhis2.org" + +S3_CMD="aws s3 cp --metadata git-commit=$GIT_COMMIT --no-progress" + +S3_DESTINATIONS=() + +RELEASE_TYPE="$1" + +if [[ -z "$1" ]]; then + echo "Error: Release type is required." + exit 1 +fi + +RELEASE_VERSION="$2" + +if [[ -z "$2" ]]; then + echo "Error: Release version is required." + exit 1 +fi + +MAJOR_VERSION=$(cut -d '.' -f 2 <<< "$RELEASE_VERSION") + +if [[ "$RELEASE_VERSION" == "master" || $MAJOR_VERSION -ge 42 ]]; then + WAR_LOCATION="${WORKSPACE}/dhis-2/dhis-web-server/target/dhis.war" +else + WAR_LOCATION="${WORKSPACE}/dhis-2/dhis-web/dhis-web-portal/target/dhis.war" +fi + +if [[ ! -f "$WAR_LOCATION" ]]; then + echo "Error: WAR file not found." + exit 1 +fi + +case $RELEASE_TYPE in + "canary") + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/$RELEASE_TYPE/dhis2-$RELEASE_TYPE-$RELEASE_VERSION.war") + + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/$RELEASE_TYPE/dhis2-$RELEASE_TYPE-$RELEASE_VERSION-$BUILD_DATE.war") + ;; + + "dev") + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/$RELEASE_TYPE/dhis2-$RELEASE_TYPE-$RELEASE_VERSION.war") + + if [[ "$RELEASE_VERSION" == "master" ]]; then + RELEASE_VERSION="dev" + fi + + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/dhis.war") + ;; + + "eos") + S3_DESTINATIONS+=("$BUCKET/$RELEASE_VERSION/dhis2-stable-$RELEASE_VERSION-$RELEASE_TYPE.war") + ;; + + "stable") + if [[ "$RELEASE_VERSION" =~ ^patch\/.* ]]; then + IS_PATCH_VERSION=1 + RELEASE_VERSION=${RELEASE_VERSION#"patch/"} + fi + + SHORT_VERSION=$(cut -d '.' -f 1,2 <<< "$RELEASE_VERSION") + + PATCH_VERSION=$(cut -d '.' -f 3 <<< "$RELEASE_VERSION") + + # Add an extra destination in S3 for the new semantic version schema without leading "2." + IFS=. read -ra RELEASE_VERSION_SEGMENTS <<< "$RELEASE_VERSION" + + NEW_RELEASE_VERSION=$(cut -d '.' -f 2- <<< "$RELEASE_VERSION") + NEW_SHORT_VERSION=$(cut -d '.' -f 2 <<< "$RELEASE_VERSION") + + if [[ "$IS_PATCH_VERSION" -eq 1 ]]; then + RELEASE_VERSION+="-rc" + # for release candidates, also add a version with the git hash + S3_DESTINATIONS+=("$BUCKET/$SHORT_VERSION/dhis2-$RELEASE_TYPE-$RELEASE_VERSION-${GIT_COMMIT:0:7}.war") + fi + + S3_DESTINATIONS+=("$BUCKET/$SHORT_VERSION/dhis2-$RELEASE_TYPE-$RELEASE_VERSION.war") + S3_DESTINATIONS+=("$BUCKET/$SHORT_VERSION/$RELEASE_VERSION/dhis.war") + + LATEST_PATCH_VERSION=$( + curl -fsSL "$VERSIONS_JSON" | + jq -r --arg VERSION "$SHORT_VERSION" '.versions[] | select(.name == $VERSION ) | .latestPatchVersion' + ) + + if [[ "$IS_PATCH_VERSION" -eq 0 && -n "${LATEST_PATCH_VERSION-}" && "$PATCH_VERSION" -ge "$LATEST_PATCH_VERSION" ]]; then + S3_DESTINATIONS+=("$BUCKET/$SHORT_VERSION/dhis2-$RELEASE_TYPE-latest.war") + S3_DESTINATIONS+=("$BUCKET/$NEW_SHORT_VERSION/dhis2-$RELEASE_TYPE-latest.war") + fi + + + if [[ ${#RELEASE_VERSION_SEGMENTS[@]} -lt 4 ]]; then + NEW_RELEASE_VERSION+=".0" + fi + + if [[ "$IS_PATCH_VERSION" -eq 1 ]]; then + NEW_RELEASE_VERSION+="-rc" + # for release candidates, also add a version with the git hash + S3_DESTINATIONS+=("$BUCKET/$NEW_SHORT_VERSION/dhis2-$RELEASE_TYPE-$NEW_RELEASE_VERSION-${GIT_COMMIT:0:7}.war") + fi + + S3_DESTINATIONS+=("$BUCKET/$NEW_SHORT_VERSION/dhis2-$RELEASE_TYPE-$NEW_RELEASE_VERSION.war") + + ;; + + *) + echo "Error: Unknown Release type." + exit 1 + ;; +esac + +for destination in "${S3_DESTINATIONS[@]}" +do + #echo "$WAR_LOCATION" "$destination" + $S3_CMD "$WAR_LOCATION" "$destination" +done diff --git a/.github/workflows/hello-world.yml b/.github/workflows/update-instance-manager.yml similarity index 81% rename from .github/workflows/hello-world.yml rename to .github/workflows/update-instance-manager.yml index d897d002c3df..4923dc9e6d68 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/update-instance-manager.yml @@ -1,4 +1,4 @@ -name: Hello World Pipeline +name: Update instance manager on: pull_request: @@ -33,9 +33,10 @@ jobs: - name: Build with Maven run: mvn --threads 4 --batch-mode --no-transfer-progress clean install --update-snapshots --file ./dhis-2/pom.xml -DskipTests + #curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O - name: Sync war run: | echo "Syncing WAR ..." - curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O - chmod +x copy-war-s3.sh - ./copy-war-s3.sh dev $GITHUB_HEAD_REF \ No newline at end of file + + chmod +x gha-copy-war-s3.sh + ./gha-copy-war-s3.sh dev $GITHUB_HEAD_REF \ No newline at end of file From d3b8fdc3cc2ed9c0f329282da31c4504b496b9c8 Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 16 Dec 2024 13:07:15 +0100 Subject: [PATCH 15/18] task: Move script to /dhis2 [DHIS2-18615] --- .github/workflows/update-instance-manager.yml | 4 ++-- {.github/workflows => dhis-2}/gha-copy-war-s3.sh | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename {.github/workflows => dhis-2}/gha-copy-war-s3.sh (100%) diff --git a/.github/workflows/update-instance-manager.yml b/.github/workflows/update-instance-manager.yml index 4923dc9e6d68..f19fa66abac1 100644 --- a/.github/workflows/update-instance-manager.yml +++ b/.github/workflows/update-instance-manager.yml @@ -38,5 +38,5 @@ jobs: run: | echo "Syncing WAR ..." - chmod +x gha-copy-war-s3.sh - ./gha-copy-war-s3.sh dev $GITHUB_HEAD_REF \ No newline at end of file + chmod +x ./dhis-2/gha-copy-war-s3.sh + ./dhis-2/gha-copy-war-s3.sh dev $GITHUB_HEAD_REF \ No newline at end of file diff --git a/.github/workflows/gha-copy-war-s3.sh b/dhis-2/gha-copy-war-s3.sh similarity index 100% rename from .github/workflows/gha-copy-war-s3.sh rename to dhis-2/gha-copy-war-s3.sh From 054c0f97889202b55ab45188d3d4ee2bfe3d2cfe Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 20 Dec 2024 08:35:00 +0100 Subject: [PATCH 16/18] task: Print release variables [DHIS2-18615] --- dhis-2/gha-copy-war-s3.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dhis-2/gha-copy-war-s3.sh b/dhis-2/gha-copy-war-s3.sh index 7d0846fdac9f..1254ccccfdf2 100644 --- a/dhis-2/gha-copy-war-s3.sh +++ b/dhis-2/gha-copy-war-s3.sh @@ -33,6 +33,8 @@ fi MAJOR_VERSION=$(cut -d '.' -f 2 <<< "$RELEASE_VERSION") +echo "Release verion: $RELEASE_VERSION" +echo "Major version: $MAJOR_VERSION" if [[ "$RELEASE_VERSION" == "master" || $MAJOR_VERSION -ge 42 ]]; then WAR_LOCATION="${WORKSPACE}/dhis-2/dhis-web-server/target/dhis.war" else From 29a64c5497d1ac5969b59289d1dc4b6e9b614581 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 20 Dec 2024 08:46:47 +0100 Subject: [PATCH 17/18] task: Use new shell script to upload war [DHIS2-18615] --- jenkinsfiles/dev | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/jenkinsfiles/dev b/jenkinsfiles/dev index f0edbc42c007..0c72f07a94d5 100644 --- a/jenkinsfiles/dev +++ b/jenkinsfiles/dev @@ -48,7 +48,7 @@ pipeline { } } - stage('Run api tests') { +/* stage('Run api tests') { environment { RP_UUID = credentials('report-portal-access-uuid') RP_ENABLE = 'true' @@ -100,15 +100,18 @@ pipeline { } } } - } + }*/ stage('Sync WAR') { steps { implementIoBuildStarted(buildName: "${STAGE_NAME}") echo 'Syncing WAR ...' - sh 'curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O' - sh 'chmod +x copy-war-s3.sh' - sh './copy-war-s3.sh dev ${GIT_BRANCH}' + //sh 'curl "https://raw.githubusercontent.com/dhis2/dhis2-server-setup/master/ci/scripts/copy-war-s3.sh" -O' + //sh 'chmod +x copy-war-s3.sh' + //sh './copy-war-s3.sh dev ${GIT_BRANCH}' + + sh 'chmod +x ./dhis-2/gha-copy-war-s3.sh' + sh './dhis-2/gha-copy-war-s3.sh dev $GIT_BRANCH' } post { @@ -118,7 +121,7 @@ pipeline { } } - stage('Publish image') { +/* stage('Publish image') { environment { // THIS MUST be kept in sync with the jib.from.image in ../dhis-2/dhis-web-server/pom.xml BASE_IMAGE = "tomcat:10.1.30-jre17" @@ -197,7 +200,7 @@ pipeline { } } } - } + }*/ } post { From 2d229e9ea61ea69c5dc71b1236b07fac82bab1aa Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 20 Dec 2024 08:57:14 +0100 Subject: [PATCH 18/18] task: Get release version [DHIS2-18615] --- .github/workflows/update-instance-manager.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-instance-manager.yml b/.github/workflows/update-instance-manager.yml index f19fa66abac1..3269e26a7613 100644 --- a/.github/workflows/update-instance-manager.yml +++ b/.github/workflows/update-instance-manager.yml @@ -37,6 +37,6 @@ jobs: - name: Sync war run: | echo "Syncing WAR ..." - + echo "Version: ${GITHUB_REF#refs/heads/}" chmod +x ./dhis-2/gha-copy-war-s3.sh ./dhis-2/gha-copy-war-s3.sh dev $GITHUB_HEAD_REF \ No newline at end of file