Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
BUILD_ARTIFACT:
required: true
type: string
FORCE_BUILD:
required: false
type: string
default: 'true'
Comment thread
Mahesh-Binayak marked this conversation as resolved.
secrets:
OSSRH_USER:
required: true
Expand All @@ -18,6 +22,8 @@ on:
required: true
GPG_SECRET:
required: true
GPG_PRIVATE_KEY:
required: true
SLACK_WEBHOOK_URL:
required: true

Expand All @@ -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: Install xmlstartlet and xmllint
run: |
Expand Down Expand Up @@ -155,6 +184,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

Expand Down
47 changes: 38 additions & 9 deletions .github/workflows/maven-publish-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
required: true
default: "android"
type: string
FORCE_BUILD:
required: false
type: string
default: 'true'
secrets:
OSSRH_USER:
required: true
Expand All @@ -23,6 +27,8 @@ on:
required: true
GPG_SECRET:
required: true
GPG_PRIVATE_KEY:
required: true
SLACK_WEBHOOK_URL:
required: true

Expand Down Expand Up @@ -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: |
Expand Down
48 changes: 38 additions & 10 deletions .github/workflows/maven-publish-to-nexus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
SERVICE_LOCATION:
required: true
type: string
FORCE_BUILD:
required: false
type: string
default: 'true'
secrets:
OSSRH_USER:
required: true
Expand All @@ -17,6 +21,8 @@ on:
required: true
GPG_SECRET:
required: true
GPG_PRIVATE_KEY:
required: true
SLACK_WEBHOOK_URL:
required: false

Expand Down Expand Up @@ -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 "<settings><servers><server><id>ossrh</id><username>${{secrets.OSSRH_USER}}</username><password>${{secrets.OSSRH_SECRET}}</password></server></servers><profiles><profile><id>ossrh</id><activation><activeByDefault>true</activeByDefault></activation><properties><gpg.executable>gpg2</gpg.executable><gpg.passphrase>${{secrets.GPG_SECRET}}</gpg.passphrase></properties></profile><profile><id>allow-snapshots</id><activation><activeByDefault>true</activeByDefault></activation><repositories><repository><id>snapshots-repo</id><url>https://central.sonatype.com/repository/maven-snapshots</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository><repository><id>releases-repo</id><url>https://central.sonatype.com/api/v1/publisher</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository><repository><id>danubetech-maven-public</id><url>https://repo.danubetech.com/repository/maven-public/</url></repository></repositories></profile><profile><id>sonar</id><properties><sonar.sources>.</sonar.sources><sonar.host.url>https://sonarcloud.io</sonar.host.url></properties><activation><activeByDefault>false</activeByDefault></activation></profile></profiles></settings>" > $GITHUB_WORKSPACE/settings.xml
Expand All @@ -68,7 +97,6 @@ jobs:
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:
GITHUB_TOKEN: ${{secrets.OSSRH_TOKEN}}
GPG_TTY: $(tty)

# - uses: 8398a7/action-slack@v3
# with:
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/maven-sonar-analysis-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ jobs:
- name: Setup env
run: |
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV

- name: Import GPG
run: |
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 Maven settings
run: |
Expand All @@ -71,6 +64,7 @@ jobs:
FULL_PROJECT_KEY="${{ secrets.ORG_KEY }}_${FINAL_NAME}"
cd "${{ inputs.SERVICE_LOCATION || '.' }}" && \
mvn -U -B verify sonar:sonar \
-Dgpg.skip=true \
-Dmaven.wagon.http.retryHandler.count=2 \
-Dsonar.projectKey=${FULL_PROJECT_KEY} \
-Dsonar.organization=${{ secrets.ORG_KEY }} \
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/maven-sonar-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<settings> <servers> <server> <id>ossrh</id> <username>${{secrets.OSSRH_USER}}</username> <password>${{secrets.OSSRH_SECRET}}</password> </server> </servers> <profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg2</gpg.executable> <gpg.passphrase>${{secrets.GPG_SECRET}}</gpg.passphrase> </properties> </profile> <profile> <id>allow-snapshots</id> <activation><activeByDefault>true</activeByDefault></activation> <repositories> <repository> <id>snapshots-repo</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>releases-repo</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> <repository> <id>danubetech-maven-public</id> <url>https://repo.danubetech.com/repository/maven-public/</url> </repository> </repositories> </profile> <profile> <id>sonar</id> <properties> <sonar.sources>.</sonar.sources> <sonar.host.url>https://sonarcloud.io</sonar.host.url> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> </profiles> </settings>" > $GITHUB_WORKSPACE/settings.xml

Expand All @@ -75,7 +64,7 @@ jobs:

- name: Analyze with SonarCloud
run: |
cd ${{ inputs.SERVICE_LOCATION }} && mvn -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_TOKEN }} --file pom.xml -s $GITHUB_WORKSPACE/settings.xml
cd ${{ inputs.SERVICE_LOCATION }} && mvn -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 }} --file pom.xml -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down