Merge pull request #4814 from roc-lang/fix_tutorial_deployment

build tutorial with roc nightly
This commit is contained in:
Ayaz 2022-12-27 07:57:14 -06:00 committed by GitHub
commit d7a3e5e1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 11 deletions

View File

@ -16,7 +16,7 @@ jobs:
run: curl https://api.github.com/repos/roc-lang/roc/releases > roc_releases.json run: curl https://api.github.com/repos/roc-lang/roc/releases > roc_releases.json
- name: get the url of today`s release for macos apple silicon - name: get the url of today`s release for macos apple silicon
run: echo "RELEASE_URL=$(./ci/get_latest_release_url.sh silicon)" >> $GITHUB_ENV run: echo "RELEASE_URL=$(./ci/get_today_release_url.sh silicon)" >> $GITHUB_ENV
- name: Get the archive from the url. - name: Get the archive from the url.
run: curl -OL ${{ env.RELEASE_URL }} run: curl -OL ${{ env.RELEASE_URL }}

View File

@ -29,11 +29,11 @@ jobs:
- name: get the url of today`s release for linux (x86_64) - name: get the url of today`s release for linux (x86_64)
if: startsWith(matrix.os, 'ubuntu') if: startsWith(matrix.os, 'ubuntu')
run: echo "RELEASE_URL=$(./ci/get_latest_release_url.sh linux_x86_64)" >> $GITHUB_ENV run: echo "RELEASE_URL=$(./ci/get_today_release_url.sh linux_x86_64)" >> $GITHUB_ENV
- name: get the url of today`s release for macos (x86_64) - name: get the url of today`s release for macos (x86_64)
if: startsWith(matrix.os, 'macos') if: startsWith(matrix.os, 'macos')
run: echo "RELEASE_URL=$(./ci/get_latest_release_url.sh macos_x86_64)" >> $GITHUB_ENV run: echo "RELEASE_URL=$(./ci/get_today_release_url.sh macos_x86_64)" >> $GITHUB_ENV
- name: get the archive from the url - name: get the archive from the url
run: curl -OL ${{ env.RELEASE_URL }} run: curl -OL ${{ env.RELEASE_URL }}

View File

@ -5,12 +5,12 @@
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euxo pipefail set -euxo pipefail
LATEST_RELEASE_URL=`cat roc_releases.json | jq --arg arch $1 --arg today $(date +'%Y-%m-%d') '.[0] | .assets | map(.browser_download_url) | map(select(. | contains("\($arch)-\($today)"))) | .[0]'` LATEST_RELEASE_URL=`cat roc_releases.json | jq --arg arch $1 '.[0] | .assets | map(.browser_download_url) | map(select(. | contains("\($arch)-"))) | last'`
if [[ "$LATEST_RELEASE_URL" == "null" ]] if [[ "$LATEST_RELEASE_URL" == "null" ]]
then then
echo "I expected to get a url but I got null instead. Today's release may not have been uploaded?" echo "I expected to get a url but I got null instead. The provided argument for this bash script may not have had any matches when used as arch in the jq query above."
exit 1 exit 1
else else
echo $LATEST_RELEASE_URL | sed s/\"//g echo $LATEST_RELEASE_URL | sed s/\"//g
fi fi

16
ci/get_today_release_url.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
# assumes roc_releases.json is present
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euxo pipefail
TODAY_RELEASE_URL=`cat roc_releases.json | jq --arg arch $1 --arg today $(date +'%Y-%m-%d') '.[0] | .assets | map(.browser_download_url) | map(select(. | contains("\($arch)-\($today)"))) | .[0]'`
if [[ "$TODAY_RELEASE_URL" == "null" ]]
then
echo "I expected to get a url but I got null instead. Today's release may not have been uploaded?"
exit 1
else
echo $TODAY_RELEASE_URL | sed s/\"//g
fi

View File

@ -52,11 +52,26 @@ mv generated-docs/ www/build/builtins # move all the folders to build/builtins/
# Manually add this tip to all the builtin docs. # Manually add this tip to all the builtin docs.
find www/build/builtins -type f -name 'index.html' -exec sed -i 's!</nav>!<div class="builtins-tip"><b>Tip:</b> <a href="/different-names">Some names</a> differ from other languages.</div></nav>!' {} \; find www/build/builtins -type f -name 'index.html' -exec sed -i 's!</nav>!<div class="builtins-tip"><b>Tip:</b> <a href="/different-names">Some names</a> differ from other languages.</div></nav>!' {} \;
# TODO to enable this, we either need to install LLVM on Netlify or get it working using the dev backend.
# echo 'Building tutorial.html from tutorial.md...' echo 'Fetching latest roc nightly...'
# mkdir www/build/tutorial curl https://api.github.com/repos/roc-lang/roc/releases > roc_releases.json
# cargo run --release run www/generate_tutorial/src/tutorial.roc -- www/generate_tutorial/src/input/ www/build/tutorial/ # get the url of the latest release
# mv www/build/tutorial/tutorial.html www/build/tutorial/index.html export ROC_RELEASE_URL=$(./ci/get_latest_release_url.sh linux_x86_64)
# get roc release archive
curl -OL $ROC_RELEASE_URL
# extract archive
ls | grep "roc_nightly" | xargs tar --one-top-level=roc_nightly -xzvf
# delete archive
ls | grep "roc_nightly.*tar.gz" | xargs rm
echo 'Building tutorial.html from tutorial.md...'
mkdir www/build/tutorial
./roc_nightly/roc version
./roc_nightly/roc run www/generate_tutorial/src/tutorial.roc -- www/generate_tutorial/src/input/ www/build/tutorial/
mv www/build/tutorial/tutorial.html www/build/tutorial/index.html
# cleanup roc
rm -rf roc_nightly roc_releases.json
echo 'Generating CLI example platform docs...' echo 'Generating CLI example platform docs...'
# Change ROC_DOCS_ROOT_DIR=builtins so that links will be generated relative to # Change ROC_DOCS_ROOT_DIR=builtins so that links will be generated relative to