|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# This is script for publishing scala on SDKMAN. |
| 4 | +# Script resolves the latest stable version of scala and then send REST request to SDKMAN Vendor API. |
| 5 | +# It's releasing and announcing the release of scala on SDKMAN. |
| 6 | +# |
| 7 | +# Requirement: |
| 8 | +# - the latest stable version of scala should be available in github artifacts |
| 9 | + |
| 10 | +set -u |
| 11 | + |
| 12 | +# latest stable dotty version |
| 13 | +DOTTY_VERSION=$(curl -s https://api.github.com/repos/lampepfl/dotty/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') |
| 14 | +DOTTY_URL="https://github.com/lampepfl/dotty/releases/download/$DOTTY_VERSION/scala3-$DOTTY_VERSION.zip" |
| 15 | + |
| 16 | +# checking if dotty version is available |
| 17 | +if ! curl --output /dev/null --silent --head --fail "$DOTTY_URL"; then |
| 18 | + echo "URL doesn't exist: $DOTTY_URL" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +# Release a new Candidate Version |
| 23 | +curl --silent --show-error --fail \ |
| 24 | + -X POST \ |
| 25 | + -H "Consumer-Key: $SDKMAN_KEY" \ |
| 26 | + -H "Consumer-Token: $SDKMAN_TOKEN" \ |
| 27 | + -H "Content-Type: application/json" \ |
| 28 | + -H "Accept: application/json" \ |
| 29 | + -d '{"candidate": "scala", "version": "'"$DOTTY_VERSION"'", "url": "'"$DOTTY_URL"'"}' \ |
| 30 | + https://vendors.sdkman.io/release |
| 31 | + |
| 32 | +if [[ $? -ne 0 ]]; then |
| 33 | + echo "Fail sending POST request to releasing scala on SDKMAN." |
| 34 | + exit 1 |
| 35 | +fi |
| 36 | + |
| 37 | +# Set DOTTY_VERSION as Default for Candidate |
| 38 | +curl --silent --show-error --fail \ |
| 39 | + -X PUT \ |
| 40 | + -H "Consumer-Key: $SDKMAN_KEY" \ |
| 41 | + -H "Consumer-Token: $SDKMAN_TOKEN" \ |
| 42 | + -H "Content-Type: application/json" \ |
| 43 | + -H "Accept: application/json" \ |
| 44 | + -d '{"candidate": "scala", "version": "'"$DOTTY_VERSION"'"}' \ |
| 45 | + https://vendors.sdkman.io/default |
| 46 | + |
| 47 | +if [[ $? -ne 0 ]]; then |
| 48 | + echo "Fail sending PUT request to announcing the release of scala on SDKMAN." |
| 49 | + exit 1 |
| 50 | +fi |
0 commit comments