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
103+ if : steps.check_npm.outputs.npm_exists == 'false' || steps.check_maven.outputs.maven_exists == 'false'
59104 run : mvn -B deploy -Prelease-npm --settings .github/workflows/maven/settings.xml
60105 env :
61106 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -64,9 +109,12 @@ jobs:
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
0 commit comments