diff --git a/.github/workflows/dkml.yml b/.github/workflows/dkml.yml index 6ae20e2..72fa248 100644 --- a/.github/workflows/dkml.yml +++ b/.github/workflows/dkml.yml @@ -121,3 +121,39 @@ jobs: - name: Teardown DkML compilers on a Linux host if: startsWith(matrix.dkml_host_abi, 'linux_') uses: ./.ci/dkml-compilers/gh-linux/post + + # Upload artifact + + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.dkml_host_abi }} + path: dist/ + + #-------- + # Release + #-------- + + release: + runs-on: ubuntu-latest + permissions: + contents: write # Needed for softprops/action-gh-release@v1 + # Wait until `build` complete + needs: + - build + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - uses: actions/download-artifact@v3 + with: + path: dist + + - name: Restructure multi-ABI directories + run: ci/prepare-release.sh + + - name: Release (only when Git tag pushed) + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + _release/* diff --git a/ci/build-test.sh b/ci/build-test.sh index 46ce084..d516fec 100755 --- a/ci/build-test.sh +++ b/ci/build-test.sh @@ -43,12 +43,19 @@ if [ -x /usr/bin/cygpath ]; then PROJECT_DIR=$(/usr/bin/cygpath -au "$PROJECT_DIR") fi +dkml_version=$(cat "$PROJECT_DIR/src/runtimelib/version.txt") + # shellcheck disable=SC2154 echo " ============= build-test.sh ============= . +---- +DkML +---- +$dkml_version +. --------- Arguments --------- @@ -78,6 +85,56 @@ opamrun exec -- ocamlc -config # Update opamrun update +# Reset repository to match the current version of DkML, not the dkml-workflows' version +opamrun repository remove diskuv --all || true +opamrun repository add diskuv "git+https://github.com/diskuv/diskuv-opam-repository.git#$dkml_version" + # Make your own build logic! It may look like ... opamrun install . --deps-only --with-test --yes -opamrun exec -- dune runtest +case "$dkml_host_abi" in +darwin_x86_64) + toolchain=darwin_arm64;; +*) + toolchain='' +esac +if [ -n "$toolchain" ]; then + opamrun exec -- dune build -x "$toolchain" +else + opamrun exec -- dune build +fi + +# ------------ Verbatim from diskuvbox (plus for OPAM_PKGNAME loop) -------------- + +# Prereq: Diagnostics +case "${dkml_host_abi}" in +linux_*) + if command -v apk; then + apk add file + fi ;; +esac + +# Copy the installed binaries (including cross-compiled ones) from Opam into dist/ folder. +# Name the binaries with the target ABI since GitHub Releases are flat namespaces. +install -d dist/ +mv _build/install/default "_build/install/default.${dkml_host_abi}" +set +f +for OPAM_PKGNAME in dkml with-dkml; do +for i in _build/install/default.*; do + target_abi=$(basename "$i" | sed s/default.//) + if [ -e "_build/install/default.${target_abi}/bin/${OPAM_PKGNAME}.exe" ]; then + install -v "_build/install/default.${target_abi}/bin/${OPAM_PKGNAME}.exe" "dist/${target_abi}-${OPAM_PKGNAME}.exe" + file "dist/${target_abi}-${OPAM_PKGNAME}.exe" + else + install -v "_build/install/default.${target_abi}/bin/${OPAM_PKGNAME}" "dist/${target_abi}-${OPAM_PKGNAME}" + file "dist/${target_abi}-${OPAM_PKGNAME}" + fi +done +done + +# For Windows you must ask your users to first install the vc_redist executable. +# Confer: https://github.com/diskuv/dkml-workflows#distributing-your-windows-executables +case "${dkml_host_abi}" in +windows_x86_64) wget -O dist/vc_redist.x64.exe https://aka.ms/vs/17/release/vc_redist.x64.exe ;; +windows_x86) wget -O dist/vc_redist.x86.exe https://aka.ms/vs/17/release/vc_redist.x86.exe ;; +windows_arm64) wget -O dist/vc_redist.arm64.exe https://aka.ms/vs/17/release/vc_redist.arm64.exe ;; +esac diff --git a/ci/prepare-release.sh b/ci/prepare-release.sh new file mode 100755 index 0000000..0673efe --- /dev/null +++ b/ci/prepare-release.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# ------------ Verbatim from diskuvbox -------------- +set -euf + +# Restructure multi-ABI directories +_release="$(pwd)/_release" +install -d "$_release" + +cd dist +find . -mindepth 1 -maxdepth 1 -type d | while read -r distname; do + rsync -av "$distname/" "$_release" +done +cd .. + +# Display files to be distributed +cd _release +ls -R +cd ..