Skip to content

Commit

Permalink
Automate releases to SDKMAN (scala#13885)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski authored and olsdavis committed Apr 4, 2022
1 parent 5985dd1 commit afbd0f8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions .github/workflows/scripts/publish-sdkman.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/docs/contributing/checklist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)'

Expand Down

0 comments on commit afbd0f8

Please sign in to comment.