Skip to content

Commit

Permalink
feat(release) add the ability to override release default repository …
Browse files Browse the repository at this point in the history
…and package naming (#10)

* feat(release) add the ability to override release default repository / package naming

* docs(releasing) update release doc to include example default release

* docs(example) adjust example bintray output sample
  • Loading branch information
hutchic authored Nov 28, 2018
1 parent 1cb4274 commit 4fdcfde
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 14 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,40 @@ export RESTY_IMAGE_TAG=seeabove
export KONG_PACKAGE_NAME=somename
export KONG_VERSION=1.2.3
make release-kong
```

Required release ENV variables:
```
BINTRAY_USR
BINTRAY_KEY
```

Required release ENV variables that have defaults if they are not set:
```
RESTY_IMAGE_BASE
RESTY_IMAGE_TAG
KONG_PACKAGE_NAME
KONG_VERSION
```

Optional release ENV variables:
```
REPOSITORY_TYPE
REPOSITORY_NAME
REPOSITORY_OS_NAME
```

The defaults when the optional arguments aren't passed are (in the following order ubuntu|rhel|centos|alpine):
```
REPOSITORY_TYPE=deb|deb|rpm|generic
REPOSITORY_NAME=$KONG_PACKAGE_NAME-$REPOSITORY_TYPE
REPOSITORY_OS_NAME=ubuntu|rhel|centos|alpine-tar
bintray.com/kong/$REPOSITORY_NAME/$REPOSITORY_OS_NAME/$KONG_VERSION/$KONG_PACKAGE_NAME-$KONG_VERSION.$OUTPUT_FILE_SUFFIX
```

Using all defaults one would end up with

```
bintray.com/kong/kong-community-edition/ubuntu/0.0.0/kong-community-edition-0.0.0.xenial.all.deb
```
36 changes: 22 additions & 14 deletions release-kong.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,30 @@ BINTRAY_API="https://api.bintray.com"

KONG_PACKAGE_NAME=$KONG_PACKAGE_NAME
KONG_VERSION=$KONG_VERSION
PACKAGE_TYPE=$PACKAGE_TYPE

BUILD_DIR="output"
REPOSITORY_NAME=""
BINTRAY_PUT_ARGS=""

if [ "$RESTY_IMAGE_BASE" == "ubuntu" ]; then
PACKAGE_TYPE="deb"
REPOSITORY_NAME=$KONG_PACKAGE_NAME-deb
REPOSITORY_TYPE="${REPOSITORY_TYPE:-deb}"
REPOSITORY_NAME="${REPOSITORY_NAME:-$KONG_PACKAGE_NAME-deb}"
REPOSITORY_OS_NAME="${REPOSITORY_OS_NAME:-$RESTY_IMAGE_BASE}"
OUTPUT_FILE_SUFFIX=".${RESTY_IMAGE_TAG}.all.deb"
BINTRAY_PUT_ARGS=";deb_distribution=$RESTY_IMAGE_TAG;deb_component=main;deb_architecture=i386,amd64,noarch"
elif [ "$RESTY_IMAGE_BASE" == "rhel" ]; then
PACKAGE_TYPE="rpm"
REPOSITORY_NAME=$KONG_PACKAGE_NAME-rpm
REPOSITORY_TYPE="${REPOSITORY_TYPE:-rpm}"
REPOSITORY_NAME="${REPOSITORY_NAME:-$KONG_PACKAGE_NAME-rpm}"
REPOSITORY_OS_NAME="${REPOSITORY_OS_NAME:-$RESTY_IMAGE_BASE}"
OUTPUT_FILE_SUFFIX=".rhel${RESTY_IMAGE_TAG}.noarch.rpm"
elif [ "$RESTY_IMAGE_BASE" == "centos" ]; then
PACKAGE_TYPE="rpm"
REPOSITORY_NAME=$KONG_PACKAGE_NAME-rpm
REPOSITORY_TYPE="${REPOSITORY_TYPE:-rpm}"
REPOSITORY_NAME="${REPOSITORY_NAME:-$KONG_PACKAGE_NAME-rpm}"
REPOSITORY_OS_NAME="${REPOSITORY_OS_NAME:-$RESTY_IMAGE_BASE}"
OUTPUT_FILE_SUFFIX=".el${RESTY_IMAGE_TAG}.noarch.rpm"
elif [ "$RESTY_IMAGE_BASE" == "alpine" ]; then
PACKAGE_TYPE="apk"
REPOSITORY_NAME=$KONG_PACKAGE_NAME-alpine-tar
REPOSITORY_TYPE="${REPOSITORY_TYPE:-generic}"
REPOSITORY_OS_NAME="${REPOSITORY_OS_NAME:alpine-tar}"
REPOSITORY_NAME="${REPOSITORY_NAME:-$KONG_PACKAGE_NAME-alpine-tar}"
OUTPUT_FILE_SUFFIX=".apk.tar.gz"
fi

Expand Down Expand Up @@ -155,12 +157,18 @@ EOF
fi
}

create_repo "$REPOSITORY_NAME" "$PACKAGE_TYPE"
create_package "$REPOSITORY_NAME" "$RESTY_IMAGE_BASE"

echo $REPOSITORY_NAME
echo $REPOSITORY_TYPE
echo $REPOSITORY_OS_NAME
echo $KONG_VERSION
echo $DIST_FILE

create_repo "$REPOSITORY_NAME" "$REPOSITORY_TYPE"
create_package "$REPOSITORY_NAME" "$REPOSITORY_OS_NAME"

RESPONSE=$(curl -X PUT --write-out =%{http_code} -s -o - \
-u $BINTRAY_USR:$BINTRAY_KEY \
"$BINTRAY_API/content/$BINTRAY_ORG/$REPOSITORY_NAME/$RESTY_IMAGE_BASE/$KONG_VERSION/dists/$DIST_FILE$BINTRAY_PUT_ARGS" \
"$BINTRAY_API/content/$BINTRAY_ORG/$REPOSITORY_NAME/$REPOSITORY_OS_NAME/$KONG_VERSION/dists/$DIST_FILE$BINTRAY_PUT_ARGS" \
-T $DIR/$BUILD_DIR$DIST_FILE)

print_result "$REPOSITORY_NAME artifact upload" "$RESPONSE"
Expand Down

0 comments on commit 4fdcfde

Please sign in to comment.