diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml
index fdbb8ed5..760546e3 100644
--- a/.github/workflows/maven-build.yml
+++ b/.github/workflows/maven-build.yml
@@ -11,7 +11,11 @@ on:
type: string
MAVEN_NON_EXEC_ARTIFACTS:
required: false
- type: string
+ type: string
+ FORCE_BUILD:
+ required: false
+ type: string
+ default: 'true'
secrets:
OSSRH_USER:
required: true
@@ -21,6 +25,8 @@ on:
required: true
GPG_SECRET:
required: true
+ GPG_PRIVATE_KEY:
+ required: true
SLACK_WEBHOOK_URL:
required: true
@@ -47,18 +53,41 @@ jobs:
- name: Setup branch and env
run: |
- # Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
- echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
- - name: Setup branch and GPG public key
+ - name: Import GPG key
+ env:
+ GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
+ GPG_SECRET: ${{ secrets.GPG_SECRET }}
+ run: |
+ if [ -n "$GPG_PRIVATE_KEY" ]; then
+ echo "$GPG_PRIVATE_KEY" | gpg --batch --passphrase "$GPG_SECRET" --pinentry-mode loopback --import
+ else
+ echo "GPG_PRIVATE_KEY not set, skipping import"
+ fi
+
+ - name: Check GPG key age
+ env:
+ GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
+ FORCE_BUILD: ${{ inputs.FORCE_BUILD }}
run: |
- # Strip git ref prefix from version
- echo ${{ env.BRANCH_NAME }}
- echo ${{ env.GPG_TTY }}
- sudo apt-get --yes install gnupg2
- gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg
- gpg2 --quiet --batch --passphrase=${{secrets.GPG_SECRET}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg
+ if [ -z "$GPG_PRIVATE_KEY" ]; then exit 0; fi
+ CREATED=$(gpg --list-keys --with-colons 2>/dev/null | awk -F: '/^pub/{print $6; exit}')
+ if [ -z "$CREATED" ]; then exit 0; fi
+ NOW=$(date +%s)
+ AGE_DAYS=$(( (NOW - CREATED) / 86400 ))
+ AGE_YEARS=$(echo "scale=1; $AGE_DAYS / 365" | bc)
+ echo "GPG key age: $AGE_DAYS days (~$AGE_YEARS years)"
+ if [ $AGE_DAYS -gt 1095 ]; then
+ if [ "$FORCE_BUILD" = "true" ]; then
+ echo "::warning::GPG key is over 3 years old ($AGE_YEARS years). FORCE_BUILD=true — KEY ROTATION IS OVERDUE."
+ else
+ echo "::error::GPG key is over 3 years old ($AGE_YEARS years). Rotate the key or set FORCE_BUILD=true to override."
+ exit 1
+ fi
+ elif [ $AGE_DAYS -gt 730 ]; then
+ echo "::warning::GPG key is over 2 years old ($AGE_YEARS years). Schedule key rotation soon."
+ fi
- name: Install xmlstartlet and xmllint
run: |
@@ -101,6 +130,14 @@ jobs:
xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]' $F
done
+ - name: Verify dependency signatures (simplify4u pgpverify)
+ continue-on-error: true
+ run: |
+ cd ${{ inputs.SERVICE_LOCATION }} && mvn org.simplify4u.plugins:pgpverify-maven-plugin:1.19.1:check \
+ -DfailNoSignature=false \
+ -DverifySnapshots=false \
+ -s $GITHUB_WORKSPACE/settings.xml
+
- name: Build with Maven
run: cd ${{ inputs.SERVICE_LOCATION }} && mvn -U -B package -Dmaven.wagon.http.retryHandler.count=2 --file pom.xml -s $GITHUB_WORKSPACE/settings.xml
diff --git a/.github/workflows/maven-publish-android.yml b/.github/workflows/maven-publish-android.yml
index f546e6de..ae0b36e8 100644
--- a/.github/workflows/maven-publish-android.yml
+++ b/.github/workflows/maven-publish-android.yml
@@ -12,6 +12,10 @@ on:
required: true
default: "android"
type: string
+ FORCE_BUILD:
+ required: false
+ type: string
+ default: 'true'
secrets:
OSSRH_USER:
required: true
@@ -23,6 +27,8 @@ on:
required: true
GPG_SECRET:
required: true
+ GPG_PRIVATE_KEY:
+ required: true
SLACK_WEBHOOK_URL:
required: true
@@ -77,18 +83,41 @@ jobs:
- name: Setup branch and env
run: |
- # Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
- echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
- - name: Setup branch and GPG public key
+ - name: Import GPG key
+ env:
+ GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
+ GPG_SECRET: ${{ secrets.GPG_SECRET }}
+ run: |
+ if [ -n "$GPG_PRIVATE_KEY" ]; then
+ echo "$GPG_PRIVATE_KEY" | gpg --batch --passphrase "$GPG_SECRET" --pinentry-mode loopback --import
+ else
+ echo "GPG_PRIVATE_KEY not set, skipping import"
+ fi
+
+ - name: Check GPG key age
+ env:
+ GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
+ FORCE_BUILD: ${{ inputs.FORCE_BUILD }}
run: |
- # Strip git ref prefix from version
- echo ${{ env.BRANCH_NAME }}
- echo ${{ env.GPG_TTY }}
- sudo apt-get --yes install gnupg2
- gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg
- gpg2 --quiet --batch --passphrase=${{secrets.GPG_SECRET}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg
+ if [ -z "$GPG_PRIVATE_KEY" ]; then exit 0; fi
+ CREATED=$(gpg --list-keys --with-colons 2>/dev/null | awk -F: '/^pub/{print $6; exit}')
+ if [ -z "$CREATED" ]; then exit 0; fi
+ NOW=$(date +%s)
+ AGE_DAYS=$(( (NOW - CREATED) / 86400 ))
+ AGE_YEARS=$(echo "scale=1; $AGE_DAYS / 365" | bc)
+ echo "GPG key age: $AGE_DAYS days (~$AGE_YEARS years)"
+ if [ $AGE_DAYS -gt 1095 ]; then
+ if [ "$FORCE_BUILD" = "true" ]; then
+ echo "::warning::GPG key is over 3 years old ($AGE_YEARS years). FORCE_BUILD=true — KEY ROTATION IS OVERDUE."
+ else
+ echo "::error::GPG key is over 3 years old ($AGE_YEARS years). Rotate the key or set FORCE_BUILD=true to override."
+ exit 1
+ fi
+ elif [ $AGE_DAYS -gt 730 ]; then
+ echo "::warning::GPG key is over 2 years old ($AGE_YEARS years). Schedule key rotation soon."
+ fi
- name: Install xmlstartlet and xmllint
run: |
diff --git a/.github/workflows/maven-publish-to-nexus.yml b/.github/workflows/maven-publish-to-nexus.yml
index c55040eb..5d77bd7e 100644
--- a/.github/workflows/maven-publish-to-nexus.yml
+++ b/.github/workflows/maven-publish-to-nexus.yml
@@ -6,6 +6,10 @@ on:
SERVICE_LOCATION:
required: true
type: string
+ FORCE_BUILD:
+ required: false
+ type: string
+ default: 'true'
secrets:
OSSRH_USER:
required: true
@@ -17,6 +21,8 @@ on:
required: true
GPG_SECRET:
required: true
+ GPG_PRIVATE_KEY:
+ required: true
SLACK_WEBHOOK_URL:
required: false
@@ -44,18 +50,41 @@ jobs:
- name: Setup branch and env
run: |
- # Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
- echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
- - name: Setup branch and GPG public key
+ - name: Import GPG key
+ env:
+ GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
+ GPG_SECRET: ${{ secrets.GPG_SECRET }}
+ run: |
+ if [ -n "$GPG_PRIVATE_KEY" ]; then
+ echo "$GPG_PRIVATE_KEY" | gpg --batch --passphrase "$GPG_SECRET" --pinentry-mode loopback --import
+ else
+ echo "GPG_PRIVATE_KEY not set, skipping import"
+ fi
+
+ - name: Check GPG key age
+ env:
+ GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
+ FORCE_BUILD: ${{ inputs.FORCE_BUILD }}
run: |
- # Strip git ref prefix from version
- echo ${{ env.BRANCH_NAME }}
- echo ${{ env.GPG_TTY }}
- sudo apt-get --yes install gnupg2
- gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg
- gpg2 --quiet --batch --passphrase=${{secrets.GPG_SECRET}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg
+ if [ -z "$GPG_PRIVATE_KEY" ]; then exit 0; fi
+ CREATED=$(gpg --list-keys --with-colons 2>/dev/null | awk -F: '/^pub/{print $6; exit}')
+ if [ -z "$CREATED" ]; then exit 0; fi
+ NOW=$(date +%s)
+ AGE_DAYS=$(( (NOW - CREATED) / 86400 ))
+ AGE_YEARS=$(echo "scale=1; $AGE_DAYS / 365" | bc)
+ echo "GPG key age: $AGE_DAYS days (~$AGE_YEARS years)"
+ if [ $AGE_DAYS -gt 1095 ]; then
+ if [ "$FORCE_BUILD" = "true" ]; then
+ echo "::warning::GPG key is over 3 years old ($AGE_YEARS years). FORCE_BUILD=true — KEY ROTATION IS OVERDUE."
+ else
+ echo "::error::GPG key is over 3 years old ($AGE_YEARS years). Rotate the key or set FORCE_BUILD=true to override."
+ exit 1
+ fi
+ elif [ $AGE_DAYS -gt 730 ]; then
+ echo "::warning::GPG key is over 2 years old ($AGE_YEARS years). Schedule key rotation soon."
+ fi
- name: Setup the settings file for ossrh server
run: echo " ossrh ${{secrets.OSSRH_USER}} ${{secrets.OSSRH_SECRET}} ossrh true gpg2 ${{secrets.GPG_SECRET}} allow-snapshots true snapshots-repo https://central.sonatype.com/repository/maven-snapshots false true releases-repo https://central.sonatype.com/api/v1/publisher true false danubetech-maven-public https://repo.danubetech.com/repository/maven-public/ sonar . https://sonarcloud.io false " > $GITHUB_WORKSPACE/settings.xml
@@ -66,8 +95,6 @@ jobs:
- name: Publish the maven package
run: |
cd ${{ inputs.SERVICE_LOCATION }} && mvn -DskipTests -U -B deploy -Dmaven.wagon.http.retryHandler.count=2 -DaltDeploymentRepository=ossrh::default::${{ secrets.OSSRH_URL }} -s $GITHUB_WORKSPACE/settings.xml -f pom.xml
- env:
- GPG_TTY: $(tty)
# - uses: 8398a7/action-slack@v3
# with:
diff --git a/.github/workflows/maven-sonar-analysis.yml b/.github/workflows/maven-sonar-analysis.yml
index 4f83b0e8..9e619ee7 100644
--- a/.github/workflows/maven-sonar-analysis.yml
+++ b/.github/workflows/maven-sonar-analysis.yml
@@ -53,20 +53,9 @@ jobs:
- name: Setup branch and env
run: |
- # Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
- echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
echo "SONAR URL : ${{ inputs.SONAR_URL }}"
- - name: Setup branch and GPG public key
- run: |
- # Strip git ref prefix from version
- echo ${{ env.BRANCH_NAME }}
- echo ${{ env.GPG_TTY }}
- sudo apt-get --yes install gnupg2
- gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg
- gpg2 --quiet --batch --passphrase=${{secrets.GPG_SECRET}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg
-
- name: Setup the settings file for ossrh server
run: echo "ossrh${{secrets.OSSRH_USER}}${{secrets.OSSRH_SECRET}}ossrhtruegpg2${{secrets.GPG_SECRET}}allow-snapshotstruesnapshots-repohttps://central.sonatype.com/repository/maven-snapshotsfalsetruereleases-repohttps://central.sonatype.com/api/v1/publishertruefalsedanubetech-maven-publichttps://repo.danubetech.com/repository/maven-public/nexus-snapshotshttps://oss.sonatype.org/content/repositories/snapshotssonar.https://sonarcloud.iofalse" > $GITHUB_WORKSPACE/settings.xml
@@ -75,7 +64,7 @@ jobs:
- name: Analyze with SonarCloud
run: |
- cd ${{ inputs.SERVICE_LOCATION }} && mvn -Psonar -U -B verify sonar:sonar -Dmaven.wagon.http.retryHandler.count=2 -Dsonar.projectKey=${{ inputs.PROJECT_KEY }} -Dsonar.organization=${{ secrets.ORG_KEY }} -Dsonar.host.url=${{ inputs.SONAR_URL }} -Dsonar.token=${{ secrets.SONAR_TOKEN1 }} -Dsonar.projectName=${{ github.event.repository.name }} --file pom.xml -s $GITHUB_WORKSPACE/settings.xml
+ cd ${{ inputs.SERVICE_LOCATION }} && mvn -Psonar -U -B verify sonar:sonar -Dgpg.skip=true -Dmaven.wagon.http.retryHandler.count=2 -Dsonar.projectKey=${{ inputs.PROJECT_KEY }} -Dsonar.organization=${{ secrets.ORG_KEY }} -Dsonar.host.url=${{ inputs.SONAR_URL }} -Dsonar.token=${{ secrets.SONAR_TOKEN }} -Dsonar.projectName=${{ github.event.repository.name }} --file pom.xml -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}