diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 000000000000..2bb6d3e49282 --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,24 @@ +name: Releases +on: + workflow_dispatch: + +jobs: + publish_release: + runs-on: [self-hosted, Linux] + container: + image: lampepfl/dotty:2021-03-22 + options: --cpu-shares 4096 + + env: + SDKMAN_KEY: ${{ secrets.SDKMAN_KEY }} + SDKMAN_TOKEN: ${{ secrets.SDKMAN_TOKEN }} + + steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + + - name: Cleanup + run: .github/workflows/cleanup.sh + + - name: Publish to SDKMAN + run: .github/workflows/scripts/publish-sdkman.sh diff --git a/.github/workflows/scripts/publish-sdkman.sh b/.github/workflows/scripts/publish-sdkman.sh new file mode 100755 index 000000000000..07d35a72a65e --- /dev/null +++ b/.github/workflows/scripts/publish-sdkman.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# This is script for publishing scala on SDKMAN. +# Script resolves the latest stable version of scala and then send REST request to SDKMAN Vendor API. +# It's releasing and announcing the release of scala on SDKMAN. +# +# Requirement: +# - the latest stable version of scala should be available in github artifacts + +set -u + +# latest stable dotty version +DOTTY_VERSION=$(curl -s https://api.github.com/repos/lampepfl/dotty/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +DOTTY_URL="https://github.com/lampepfl/dotty/releases/download/$DOTTY_VERSION/scala3-$DOTTY_VERSION.zip" + +# checking if dotty version is available +if ! curl --output /dev/null --silent --head --fail "$DOTTY_URL"; then + echo "URL doesn't exist: $DOTTY_URL" + exit 1 +fi + +# Release a new Candidate Version +curl --silent --show-error --fail \ + -X POST \ + -H "Consumer-Key: $SDKMAN_KEY" \ + -H "Consumer-Token: $SDKMAN_TOKEN" \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -d '{"candidate": "scala", "version": "'"$DOTTY_VERSION"'", "url": "'"$DOTTY_URL"'"}' \ + https://vendors.sdkman.io/release + +if [[ $? -ne 0 ]]; then + echo "Fail sending POST request to releasing scala on SDKMAN." + exit 1 +fi + +# Set DOTTY_VERSION as Default for Candidate +curl --silent --show-error --fail \ + -X PUT \ + -H "Consumer-Key: $SDKMAN_KEY" \ + -H "Consumer-Token: $SDKMAN_TOKEN" \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -d '{"candidate": "scala", "version": "'"$DOTTY_VERSION"'"}' \ + https://vendors.sdkman.io/default + +if [[ $? -ne 0 ]]; then + echo "Fail sending PUT request to announcing the release of scala on SDKMAN." + exit 1 +fi diff --git a/docs/docs/contributing/checklist.sh b/docs/docs/contributing/checklist.sh index 827f0911d84d..d3cfe70b4e21 100755 --- a/docs/docs/contributing/checklist.sh +++ b/docs/docs/contributing/checklist.sh @@ -48,6 +48,7 @@ LIST='- [ ] Publish artifacts to Maven via CI - [ ] Publish Blog Post on dotty.epfl.ch - [ ] Make an announcement thread on https://contributors.scala-lang.org - [ ] Tweet the announcement blog post on https://twitter.com/scala_lang + - [ ] Run workflow releases CI to publish scala on SDKMAN - https://github.com/lampepfl/dotty/actions/workflows/releases.yml [Instructions on how to release](https://dotty.epfl.ch/docs/contributing/release.html)'