-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3629 from djspiewak/build/make-site-pr
- Loading branch information
Showing
3 changed files
with
112 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,8 @@ | ||
scalacOptions ++= Seq( | ||
"-deprecation", | ||
"-encoding", "UTF-8", | ||
"-feature", | ||
"-unchecked" | ||
) | ||
|
||
turbo := false |
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,30 @@ | ||
import cats.effect.{IO, IOApp} | ||
import cats.effect.std.Random | ||
|
||
import scala.concurrent.duration._ | ||
|
||
object Hello extends IOApp.Simple { | ||
|
||
def sleepPrint(word: String, name: String, rand: Random[IO]) = | ||
for { | ||
delay <- rand.betweenInt(200, 700) | ||
_ <- IO.sleep(delay.millis) | ||
_ <- IO.println(s"$word, $name") | ||
} yield () | ||
|
||
val run = | ||
for { | ||
rand <- Random.scalaUtilRandom[IO] | ||
|
||
// try uncommenting first one locally! Scastie doesn't like System.in | ||
// name <- IO.print("Enter your name: ") >> IO.readLine | ||
name <- IO.pure("Daniel") | ||
|
||
english <- sleepPrint("Hello", name, rand).foreverM.start | ||
french <- sleepPrint("Bonjour", name, rand).foreverM.start | ||
spanish <- sleepPrint("Hola", name, rand).foreverM.start | ||
|
||
_ <- IO.sleep(5.seconds) | ||
_ <- english.cancel >> french.cancel >> spanish.cancel | ||
} yield () | ||
} |
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,74 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
cd "$(dirname $0)/.." | ||
primary_base="$(pwd)" | ||
|
||
if [[ $# -ne 2 ]] || [[ "$1" == "--help" ]]; then | ||
echo "usage: $0 old-version new-version" | ||
exit 1 | ||
fi | ||
|
||
old_version="$1" | ||
new_version="$2" | ||
|
||
cd "$(mktemp -d)" | ||
git clone [email protected]:typelevel/cats-effect.git | ||
cd 'cats-effect' | ||
|
||
git checkout origin/docs | ||
git submodule init | ||
|
||
branch=release/$new_version-site | ||
git checkout -b $branch | ||
|
||
scastie_scala_string="$(jq -R -s '.' < "${primary_base}/scripts/data/scastie.scala")" | ||
|
||
scastie_sbt_full="$(cat << SBT | ||
$(cat "${primary_base}/scripts/data/scastie.sbt") | ||
libraryDependencies += "org.typelevel" %% "cats-effect" % "$new_version" | ||
SBT | ||
)" | ||
|
||
scastie_sbt_string="$(echo "$scastie_sbt_full" | jq -R -s '.')" | ||
|
||
post_file="$(mktemp)" | ||
cat > "$post_file" << JSON | ||
{ | ||
"_isWorksheetMode": false, | ||
"code": $scastie_scala_string, | ||
"isShowingInUserProfile": false, | ||
"libraries": [], | ||
"librariesFromList": [], | ||
"sbtConfigExtra": $scastie_sbt_string, | ||
"sbtPluginsConfigExtra": "", | ||
"target": { | ||
"scalaVersion": "2.13.10", | ||
"tpe": "Jvm" | ||
} | ||
} | ||
JSON | ||
|
||
# echo "$post_body" | jq | ||
|
||
uuid=$(curl \ | ||
-X POST \ | ||
-H 'Content-Type: application/json' \ | ||
-d "@$post_file" \ | ||
https://scastie.scala-lang.org/api/save | jq -r .base64UUID) | ||
|
||
perl -pi -e "s/\"$old_version\"/\"$new_version\"/" website/pages/en/index.js | ||
perl -pi -e "s|https://scastie.scala-lang.org/[^\"]+|https://scastie.scala-lang.org/$uuid|" website/pages/en/index.js | ||
|
||
git commit -a -m "Updated site for $new_version" | ||
git push origin $branch | ||
|
||
gh pr create \ | ||
--fill \ | ||
--base docs \ | ||
--repo typelevel/cats-effect \ | ||
--head typelevel:$branch \ | ||
--label ':robot:' |