Skip to content

Commit 7293c95

Browse files
committed
chore: gpg sign in verify phase and skip re-publish
Signed-off-by: Ruben Romero Montes <[email protected]>
1 parent ab239e1 commit 7293c95

File tree

3 files changed

+54
-9
lines changed

3 files changed

+54
-9
lines changed

.github/workflows/cicd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353

5454
- name: Build and Publish to Maven Central and NPM registry
5555
run: |
56-
mvn -B deploy -Drc.version=${{ github.run_number }} --file pom.xml --settings .github/workflows/maven/settings.xml
56+
mvn -B deploy -Pgpg-sign -Drc.version=${{ github.run_number }} --file pom.xml --settings .github/workflows/maven/settings.xml
5757
env:
5858
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5959
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yaml

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,66 @@ jobs:
5555
if: github.event.inputs.version == ''
5656
run: mvn -B versions:set -DremoveSnapshot -DgenerateBackupPoms=false
5757

58+
- name: Get version
59+
id: get_version
60+
run: echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
61+
62+
- name: Check if NPM package version exists
63+
id: check_npm
64+
run: |
65+
VERSION="${{ steps.get_version.outputs.version }}"
66+
echo "Checking if NPM package version $VERSION exists..."
67+
if npm view @trustify-da/trustify-da-api-model@$VERSION version 2>/dev/null; then
68+
echo "npm_exists=true" >> $GITHUB_OUTPUT
69+
echo "NPM package version $VERSION already exists, skipping NPM publish"
70+
else
71+
echo "npm_exists=false" >> $GITHUB_OUTPUT
72+
echo "NPM package version $VERSION does not exist, will publish"
73+
fi
74+
continue-on-error: true
75+
76+
- name: Check if Maven artifact version exists
77+
id: check_maven
78+
run: |
79+
VERSION="${{ steps.get_version.outputs.version }}"
80+
GROUP_ID="io.github.guacsec"
81+
ARTIFACT_ID="trustify-da-api-model"
82+
echo "Checking if Maven artifact $GROUP_ID:$ARTIFACT_ID:$VERSION exists..."
83+
84+
# Check Maven Central for the artifact
85+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://repo1.maven.org/maven2/io/github/guacsec/trustify-da-api-model/$VERSION/trustify-da-api-model-$VERSION.pom")
86+
if [ "$HTTP_CODE" = "200" ]; then
87+
echo "maven_exists=true" >> $GITHUB_OUTPUT
88+
echo "Maven artifact $GROUP_ID:$ARTIFACT_ID:$VERSION already exists, skipping Maven publish"
89+
else
90+
echo "maven_exists=false" >> $GITHUB_OUTPUT
91+
echo "Maven artifact $GROUP_ID:$ARTIFACT_ID:$VERSION does not exist (HTTP $HTTP_CODE), will publish"
92+
fi
93+
continue-on-error: true
94+
95+
- name: Show artifact check results
96+
run: |
97+
echo "=== Artifact Check Results ==="
98+
echo "NPM package exists: ${{ steps.check_npm.outputs.npm_exists }}"
99+
echo "Maven artifact exists: ${{ steps.check_maven.outputs.maven_exists }}"
100+
echo "Will publish: ${{ steps.check_npm.outputs.npm_exists == 'false' || steps.check_maven.outputs.maven_exists == 'false' }}"
101+
58102
- name: Build and Publish to Maven Central and NPM registry
59-
run: mvn -B deploy -Prelease-npm --settings .github/workflows/maven/settings.xml
103+
if: steps.check_npm.outputs.npm_exists == 'false' || steps.check_maven.outputs.maven_exists == 'false'
104+
run: mvn -B deploy -Pgpg-sign -Prelease-npm --settings .github/workflows/maven/settings.xml
60105
env:
61106
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62107
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
63108
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
64109
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
65110
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
66111

67-
- name: Get version
68-
id: get_version
69-
run: echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
112+
- name: Skip publishing - artifacts already exist
113+
if: steps.check_npm.outputs.npm_exists == 'true' && steps.check_maven.outputs.maven_exists == 'true'
114+
run: |
115+
echo "Both NPM package and Maven artifact already exist, skipping publish step"
116+
echo "NPM exists: ${{ steps.check_npm.outputs.npm_exists }}"
117+
echo "Maven exists: ${{ steps.check_maven.outputs.maven_exists }}"
70118
71119
- name: Create Release
72120
id: create_release

pom.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,6 @@ limitations under the License.]]>
626626
</profile>
627627
<profile>
628628
<id>gpg-sign</id>
629-
<activation>
630-
<activeByDefault>true</activeByDefault>
631-
</activation>
632629
<build>
633630
<plugins>
634631
<plugin>
@@ -637,7 +634,7 @@ limitations under the License.]]>
637634
<executions>
638635
<execution>
639636
<id>sign-artifacts</id>
640-
<phase>deploy</phase>
637+
<phase>verify</phase>
641638
<goals>
642639
<goal>sign</goal>
643640
</goals>

0 commit comments

Comments
 (0)