Skip to content

Commit

Permalink
DX-7329: release cli binaries to jfrog (#854)
Browse files Browse the repository at this point in the history
* DX-7329: release cli binaries to jfrog

* remove snoozing
  • Loading branch information
etsai-stripe committed Apr 21, 2022
1 parent 73a641d commit 6a83b84
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 10 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,7 @@ jobs:
args: release -f .goreleaser/linux.yml --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
- name: Upload to Bintray
if: ${{ false }} # Disable this step until a replacement is found
run: |
scripts/publish-deb-to-bintray.sh
scripts/publish-rpm-to-bintray.sh
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
ARTIFACTORY_SECRET: ${{ secrets.ARTIFACTORY_SECRET }}

build-windows:
runs-on: windows-latest
Expand Down
13 changes: 13 additions & 0 deletions .goreleaser/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,16 @@ dockers:
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=repository=https://github.com/stripe/stripe-cli"
- "--label=homepage=https://stripe.com"
publishers:
- name: deb
ids:
- deb
cmd: scripts/publish-to-artifactory {{ 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
env:
- ARTIFACTORY_SECRET={{ .Env.ARTIFACTORY_SECRET }}
55 changes: 55 additions & 0 deletions scripts/publish-to-artifactory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# Adapted from https://github.com/leopardslab/dunner/blob/master/release/publish_deb_to_bintray.sh

set -e

FILENAME=$1
VERSION=$2
ARCH=$3
FORMAT=$4

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"
}

printMeta () {
echo "Publishing: $PACKAGE"
echo "Version to be uploaded: $VERSION"
}

printMeta
artifactoryUpload

0 comments on commit 6a83b84

Please sign in to comment.