Skip to content

Commit c387c1d

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 c387c1d

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

.github/workflows/release.yaml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,52 @@ 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
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

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ limitations under the License.]]>
637637
<executions>
638638
<execution>
639639
<id>sign-artifacts</id>
640-
<phase>deploy</phase>
640+
<phase>verify</phase>
641641
<goals>
642642
<goal>sign</goal>
643643
</goals>

0 commit comments

Comments
 (0)