Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate releases to SDKMAN #13885

Merged
merged 3 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
lwronski marked this conversation as resolved.
Show resolved Hide resolved

# 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"
julienrf marked this conversation as resolved.
Show resolved Hide resolved

# 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
julienrf marked this conversation as resolved.
Show resolved Hide resolved

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