Skip to content

Commit 51828cc

Browse files
authored
Automate releases to SDKMAN (#13885)
1 parent d8c19be commit 51828cc

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

.github/workflows/releases.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Releases
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
publish_release:
7+
runs-on: [self-hosted, Linux]
8+
container:
9+
image: lampepfl/dotty:2021-03-22
10+
options: --cpu-shares 4096
11+
12+
env:
13+
SDKMAN_KEY: ${{ secrets.SDKMAN_KEY }}
14+
SDKMAN_TOKEN: ${{ secrets.SDKMAN_TOKEN }}
15+
16+
steps:
17+
- name: Reset existing repo
18+
run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true
19+
20+
- name: Cleanup
21+
run: .github/workflows/cleanup.sh
22+
23+
- name: Publish to SDKMAN
24+
run: .github/workflows/scripts/publish-sdkman.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

docs/docs/contributing/checklist.sh

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ LIST='- [ ] Publish artifacts to Maven via CI
4848
- [ ] Publish Blog Post on dotty.epfl.ch
4949
- [ ] Make an announcement thread on https://contributors.scala-lang.org
5050
- [ ] Tweet the announcement blog post on https://twitter.com/scala_lang
51+
- [ ] Run workflow releases CI to publish scala on SDKMAN - https://github.com/lampepfl/dotty/actions/workflows/releases.yml
5152
5253
[Instructions on how to release](https://dotty.epfl.ch/docs/contributing/release.html)'
5354

0 commit comments

Comments
 (0)