Skip to content

wip

wip #75

Workflow file for this run

name: publish-version
on:
push:
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 20
cache: yarn
- uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 5.4.0
dune-cache: false # can cause trouble when generating melange docs in step below: https://github.com/ocaml/dune/issues/7720
- name: Install all deps
run: make install
- name: Generate melange docs
run: opam reinstall -y melange --with-doc --keep-build-dir
- name: Copy melange docs in ml syntax
run: |
mkdir -p docs/public/api/
cp -r `opam var melange:build`/_build/default/_doc/_html docs/public/api/ml
- name: Generate melange docs in re syntax
run: ODOC_SYNTAX="re" opam reinstall -y melange --with-doc --keep-build-dir
- name: Copy melange docs in re syntax
run: cp -r `opam var melange:build`/_build/default/_doc/_html docs/public/api/re
- name: Diagnose CMI assumptions before playground rebuild
run: |
set -euo pipefail
RR_LIB="$(opam var reason-react:lib)"
MEL_LIB="$(opam var melange:lib)"
RR_BUILD="$(opam var reason-react:build)"
RR_REACTDOM="$(find "$RR_LIB" -path '*/melange/reactDOM.cmi' -print -quit)"
MEL_JS="$(find "$MEL_LIB" -path '*/melange/js.cmi' -print -quit)"
if [ -z "$RR_REACTDOM" ] || [ -z "$MEL_JS" ]; then
echo "Could not locate expected CMI files"
echo "reason-react lib: $RR_LIB"
echo "melange lib: $MEL_LIB"
exit 1
fi
echo "reason-react reactDOM.cmi: $RR_REACTDOM"
opam exec -- ocamlobjinfo "$RR_REACTDOM"
echo "melange js.cmi: $MEL_JS"
opam exec -- ocamlobjinfo "$MEL_JS"
echo "reason-react build melange_mini_stdlib.cmi candidates:"
find "$RR_BUILD" -name "melange_mini_stdlib.cmi" -print || true
- name: Rebuild packages for playground consistency
run: opam reinstall -y melange
- name: Verify CMI consistency for playground
run: |
set -euo pipefail
RR_LIB="$(opam var reason-react:lib)"
MEL_LIB="$(opam var melange:lib)"
RR_REACTDOM="$(find "$RR_LIB" -path '*/melange/reactDOM.cmi' -print -quit)"
MEL_JS="$(find "$MEL_LIB" -path '*/melange/js.cmi' -print -quit)"
if [ -z "$RR_REACTDOM" ] || [ -z "$MEL_JS" ]; then
echo "Could not locate expected CMI files"
exit 1
fi
js_digest="$(opam exec -- ocamlobjinfo "$MEL_JS" | awk '$2=="Js" {print $1; exit}')"
js_mini_digest="$(opam exec -- ocamlobjinfo "$MEL_JS" | awk '$2=="Melange_mini_stdlib" {print $1; exit}')"
reactdom_js_digest="$(opam exec -- ocamlobjinfo "$RR_REACTDOM" | awk '$2=="Js" {print $1; exit}')"
reactdom_mini_digest="$(opam exec -- ocamlobjinfo "$RR_REACTDOM" | awk '$2=="Melange_mini_stdlib" {print $1; exit}')"
echo "melange js.cmi Js digest: $js_digest"
echo "reason-react reactDOM.cmi Js digest: $reactdom_js_digest"
echo "melange js.cmi Melange_mini_stdlib digest: $js_mini_digest"
echo "reason-react reactDOM.cmi Melange_mini_stdlib digest: $reactdom_mini_digest"
if [ "$js_digest" != "$reactdom_js_digest" ]; then
echo "::error::reactDOM.cmi and js.cmi disagree on Js digest"
exit 1
fi
if [ "$js_mini_digest" != "$reactdom_mini_digest" ]; then
echo "::error::reactDOM.cmi and js.cmi disagree on Melange_mini_stdlib digest"
exit 1
fi
# only uncomment after a new version is released, from inside a `x.x.x-patches` branch
# - name: Run canonical script
# run: opam exec -- dune exec add_canonical docs/public/api
- name: Check Reason syntax
run: make check-reason
- name: Check extracted code blocks
run: make check-extracted-code-blocks
- name: Run tests
run: make test
- name: Build site (and playground)
run: BASE=${{ github.ref_name }} make build-site
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Fetch and checkout gh-pages
run: |
git fetch origin gh-pages --depth=1
git checkout gh-pages
- name: Copy published site into folder
run: cp -TRv docs/.vitepress/dist/ ${{ github.ref_name }}/
- name: Add ${{ github.ref_name }} files to git index
run: git add ${{ github.ref_name }}
- name: Committing
run: git commit -m 'Deployed ${{ github.sha }} to ${{ github.ref_name }}'
- name: Push
run: git push