Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single artifact releases #298

Merged
merged 4 commits into from
Aug 21, 2024
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
13 changes: 12 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,20 @@ jobs:

- name: Install dependencies
run: mvn clean install -Dgpg.skip

- name: Determine release list
run: |
chmod +x ./version_script.sh
./version_script.sh

- name: Deploy and Release artifact
run: mvn clean deploy -Dgpg.keyname=${{ secrets.MAVEN_GPG_KEYNAME }} -pl qanary_commons,qanary_pipeline-template,qanary_component-template,qanary_component-parent
run: |
if [ -z ${{ env.ARTIFACTS_TO_BE_RELEASED}} ]; then
echo "No artifacts to be released."
else
echo "Releasing artifacts: ${{ env.ARTIFACTS_TO_BE_RELEASED }}"
mvn clean deploy -Dgpg.keyname=${{ secrets.MAVEN_GPG_KEYNAME }} -pl ${{ env.ARTIFACTS_TO_BE_RELEASED }}
fi
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }}
Expand Down
32 changes: 32 additions & 0 deletions service_config/version_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

GROUP_ID="eu.wdaqua.qanary"
GROUP_PATH=$(echo "$GROUP_ID" | tr '.' '/')

artifacts=(qanary_commons qanary_pipeline-template qanary_component-template qanary_component-parent)
artifacts_to_be_released=()

for artifact in "${artifacts[@]}"; do
echo "Checking version in: $artifact"
while read -r file; do
echo "Found pom.xml in: $file"
ARTIFACT_ID=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" "$file")
VERSION=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" "$file")
echo "Artifact ID: $ARTIFACT_ID, Version: $VERSION"
URL="https://repo1.maven.org/maven2/$GROUP_PATH/$ARTIFACT_ID/$VERSION/$ARTIFACT_ID-$VERSION.pom"
HTTP_STATUS=$(curl --head --silent --output /dev/null --write-out "%{http_code}" "$URL")
# Check the HTTP status code
if [ "$HTTP_STATUS" -eq 200 ]; then
echo "Artifact $ARTIFACT_ID version $VERSION exists in Maven Central."
else
echo "Artifact $ARTIFACT_ID version $VERSION does not exist in Maven Central."
artifacts_to_be_released+=("$artifact")
fi
done < <(find "../$artifact" -name "pom.xml")
done

# Join the array elements into a string with a comma as delimiter
ARTIFACTS_TO_BE_RELEASED_STR=$(IFS=","; echo "${artifacts_to_be_released[*]}")
echo "Final list of artifacts to be released: ${ARTIFACTS_TO_BE_RELEASED_STR[@]}"
# Use GitHub Actions command to set an environment variable
echo "ARTIFACTS_TO_BE_RELEASED=$ARTIFACTS_TO_BE_RELEASED_STR" >> $GITHUB_ENV