Skip to content

Commit

Permalink
fix github action for release script (#855)
Browse files Browse the repository at this point in the history
* fix github action for release

* address comments
  • Loading branch information
etsai-stripe committed Apr 22, 2022
1 parent 6a83b84 commit 946349d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .goreleaser/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ publishers:
- name: deb
ids:
- deb
cmd: scripts/publish-to-artifactory {{ abs .ArtifactPath }} {{ .Version }} {{ .Arch }} debian
cmd: scripts/publish-to-artifactory.sh {{ abs .ArtifactPath }} {{ .Version }} {{ .Arch }} debian
env:
- ARTIFACTORY_SECRET={{ .Env.ARTIFACTORY_SECRET }}
- name: rpm
ids:
- rpm
cmd: scripts/publish-to-artifactory {{ abs .ArtifactPath }} {{ .Version }} {{ .Arch }} rpm
cmd: scripts/publish-to-artifactory.sh {{ abs .ArtifactPath }} {{ .Version }} {{ .Arch }} rpm
env:
- ARTIFACTORY_SECRET={{ .Env.ARTIFACTORY_SECRET }}
55 changes: 31 additions & 24 deletions scripts/publish-to-artifactory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,44 @@ REPO="stripe-cli-$FORMAT"
PACKAGE="stripe"
DISTRIBUTIONS="stable"
COMPONENTS="main"
DEBIAN_META=""
UPLOAD_URL=""

if [ -z "$ARTIFACTORY_SECRET" ]; then
echo "ARTIFACTORY_SECRET is not set"
exit 1
fi

artifactoryUpload () {
if [ "$ARCH" == "386" ]; then
ARCH="i386"
fi

if [ "$FORMAT" == "debian" ]; then
DEBIAN_META="deb.distribution=$DISTRIBUTIONS;deb.component=$COMPONENTS;deb.architecture=$ARCH"
UPLOAD_URL="https://stripe.jfrog.io/artifactory/$REPO-local/pool/$PACKAGE/$VERSION/$PACKAGE$DEBIAN_META"
elif [ "$FORMAT" == "rpm" ]; then
UPLOAD_URL="https://stripe.jfrog.io/artifactory/$REPO-local/$PACKAGE/$VERSION/$ARCH/$PACKAGE"
else
echo "unrecognised package format"
exit 1
fi

echo "Uploading $UPLOAD_URL"

RESPONSE_CODE=$(curl -X PUT -T "$FILENAME" -H "Authorization: Bearer $ARTIFACTORY_SECRET" "$UPLOAD_URL" -I -s -w "%{http_code}" -o /dev/null);
if [[ "$(echo "$RESPONSE_CODE" | head -c2)" != "20" ]]; then
echo "Unable to upload, HTTP response code: $RESPONSE_CODE"
exit 1
fi
echo "HTTP response code: $RESPONSE_CODE"
if [ "$ARCH" == "386" ]; then
ARCH="i386"
fi

if [[ $FORMAT == "debian" ]]
then
if [ $ARCH == "x86_64" ]; then
ARCH="amd64"
fi

echo "setting deployment to debian repo"
UPLOAD_URL="https://stripe.jfrog.io/artifactory/$REPO-local/pool/$PACKAGE/$VERSION/$ARCH/$PACKAGE.deb;deb.distribution=$DISTRIBUTIONS;deb.component=$COMPONENTS;deb.architecture=$ARCH"
elif [[ $FORMAT == "rpm" ]]
then
echo "setting deployment to rpm repo"
UPLOAD_URL="https://stripe.jfrog.io/artifactory/$REPO-local/$PACKAGE/$VERSION/$ARCH/$PACKAGE.rpm"
else
echo "unrecognised package format"
exit 1
fi

echo "Uploading $UPLOAD_URL"

RESPONSE_CODE=$(curl -X PUT -T "$FILENAME" -H "Authorization: Bearer $ARTIFACTORY_SECRET" "$UPLOAD_URL" -I -s -w "%{http_code}" -o /dev/null)

if [[ "$(echo "$RESPONSE_CODE" | head -c2)" != "20" ]]; then
echo "Unable to upload, HTTP response code: $RESPONSE_CODE"
exit 1
fi

echo "HTTP response code: $RESPONSE_CODE"
}

printMeta () {
Expand Down

0 comments on commit 946349d

Please sign in to comment.