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

Prevent publishing same version #204

Merged
Merged
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
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,41 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
# Check whether gradle.properties version has been released already
# This prevents accidently publish same version
# Only check binary for arithmetic as all published together and arithmetic is the first
- name: Check release published
run: |
# Only interested in release version
if [[ $(grep -E 'version=[0-9]+\.[0-9]+\.[0-9]+$' gradle.properties | wc -l) -ne 0 ]]
then
# Extract version from gradle.properties
VERSION=$(grep "^version" gradle.properties | sed 's|^version=\(.*\)$|\1|g')
echo "Query for version [$VERSION]"
RESPONSE_CODE=$(curl --head -L --silent --output /dev/null --write-out %{http_code} "$ART_URL/$VERSION")
echo "Response code for curl command [$RESPONSE_CODE]"
if [[ $RESPONSE_CODE == "404" ]]
cdivitotawela marked this conversation as resolved.
Show resolved Hide resolved
then
echo "Version [$VERSION] has not yet been published"
else
if [[ $RESPONSE_CODE == "200" ]]
then
echo "ERROR: Binary arithmetic already exists for version [$VERSION]"
echo "ERROR: Blocking republishing same version to the Besu Artifactory"
echo "url $ART_URL/$VERSION"
exit 1
else
echo "WARN: Unable to check whether version has been published previously"
echo "WARN: Failing job due to unknown status"
exit 1
fi

fi
else
echo "No validation as not a release version"
fi
env:
ART_URL: 'https://hyperledger.jfrog.io/artifactory/besu-maven/org/hyperledger/besu/arithmetic'
- name: Build
run: ./build.sh
- uses: actions/upload-artifact@v3.1.0
Expand Down
Loading