@@ -193,21 +193,27 @@ jobs:
193193 exit 0
194194 fi
195195
196- echo "Uploading firmware to artifactory"
197- aws s3 cp --endpoint-url $AWS_ENDPOINT_URL firmware.zip s3://expresslrs/ExpressLRS/$GITHUB_SHA/firmware.zip
198-
199- echo "Generating artifact index"
200- aws s3 ls --endpoint-url $AWS_ENDPOINT_URL s3://expresslrs/ExpressLRS/ | awk '{print $2}' | sed s/\\/// > /tmp/hashes
201- echo '{' > index.json
202- echo '"branches": {' >> index.json
203- git branch --list --remotes --format '"%(refname:short)": "%(objectname)",' | grep origin/ | sed s/origin.// | grep -f /tmp/hashes | head -c-2 >> index.json
204- echo '' >> index.json
205- echo '},' >> index.json
206- echo '"tags": {' >> index.json
207- git tag --list --format '"%(refname:short)": "%(objectname)",' | grep -f /tmp/hashes | head -c-2 >> index.json
208- echo '' >> index.json
209- echo '}' >> index.json
210- echo '}' >> index.json
211-
212- echo "Uploading artifact index"
213- aws s3 cp --endpoint-url $AWS_ENDPOINT_URL index.json s3://expresslrs/ExpressLRS/index.json
196+ aws s3api head-object --endpoint-url $AWS_ENDPOINT_URL --bucket expresslrs --key ExpressLRS/$GITHUB_SHA/firmware.zip > /dev/null || NOT_EXIST=true
197+ if [ $NOT_EXIST ]; then
198+ echo "Uploading firmware to artifactory"
199+ aws s3 cp --endpoint-url $AWS_ENDPOINT_URL firmware.zip s3://expresslrs/ExpressLRS/$GITHUB_SHA/firmware.zip
200+
201+ echo "Generating artifact index"
202+ aws s3 ls --endpoint-url $AWS_ENDPOINT_URL s3://expresslrs/ExpressLRS/ | awk '{print $2}' | sed s/\\/// > /tmp/hashes
203+ echo '{' > index.json
204+ echo '"branches": {' >> index.json
205+ git branch --list --remotes --format '"%(refname:short)": "%(objectname)",' | grep origin/ | sed s/origin.// | grep -f /tmp/hashes | head -c-2 >> index.json
206+ echo '' >> index.json
207+ echo '},' >> index.json
208+ echo '"tags": {' >> index.json
209+ git tag --list --format '"%(refname:short)": "%(objectname)",' | grep -f /tmp/hashes | head -c-2 >> index.json
210+ echo '' >> index.json
211+ echo '}' >> index.json
212+ echo '}' >> index.json
213+
214+ echo "Uploading artifact index"
215+ aws s3 cp --endpoint-url $AWS_ENDPOINT_URL index.json s3://expresslrs/ExpressLRS/index.json
216+ else
217+ echo "Not overwriting already existing artifact at $GITHUB_SHA"
218+ exit 1
219+ fi
0 commit comments