forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate releases to SDKMAN (scala#13885)
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters