diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bedddeafc7f..6d086e3d1f7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -82,14 +82,73 @@ jobs: run: | bash scripts/build_otp_macos.bash "${{ env.OTP_REF_NAME }}" + # - name: Set up Git credentials + # env: + # # This is a personal access token for user wojtekmach-erlef-bot that has write access. + # # We need a token with `workflows` permissions because by pushing git tags + # # (from upstream, erlang/otp) we're modifying workflow files (.github/workflows) + # # on those tags and that is restricted. Perhaps this would be not necessary if this repo + # # was a _fork_ of erlang/otp. + # GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + # run: | + # git config --global credential.helper store + # echo "https://x-access-token:${GITHUB_TOKEN}@github.com" > ~/.git-credentials + - name: "Upload" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + if [ "${OTP_REF_NAME}" = master ] || echo "${OTP_REF_NAME}" | grep -q "^maint"; then + ref_name="${OTP_REF_NAME}-latest" + else + ref_name="${OTP_REF_NAME}" + fi + + # TODO: + # git remote add upstream https://github.com/erlang/otp + # git fetch upstream + # git tag $ref_name $OTP_REF --force + # git push origin $ref_name --force + + if ! gh release view $ref_name; then + if ! echo "$REF_NAME" | grep -qE 'rc|maint|master'; then + if [ -f builds/macos-arm64.txt ]; then + latest_version=`cat builds/macos-arm64.txt | cut -d" " -f1 | grep OTP- | sed 's/OTP-//' | sort --reverse -V | head -1` + version=$(echo "$ref_name" | sed 's/OTP-//') + + if [ $(printf "%s\n%s" "$latest_version" "$version" | sort --reverse -V | head -1) != "$latest_version" ]; then + latest="--latest" + else + latest="--latest=false" + fi + else + latest="--latest=false" + fi + else + latest="--latest=false" + fi + + # Initial commit + target=b5893a3c3a8d0ab54be5d04de450b24d9e5aa149 + + gh release create \ + --repo ${{ github.repository }} \ + --title $ref_name \ + --notes "Automated build for https://github.com/erlang/otp/tree/${OTP_REF_NAME}." \ + --target $target \ + $latest \ + $ref_name + fi + tgz="$OTP_REF_NAME-macos-${{ matrix.pair.arch }}.tar.gz" tar czf $tgz --cd $OTP_DIR . - gh release create $OTP_REF_NAME || true - gh release upload --clobber $OTP_REF_NAME $tgz + + gh release upload \ + --repo ${{ github.repository }} \ + --clobber \ + $ref_name \ + $tgz + gh workflow run update_builds_txt.yaml \ --repo "${GITHUB_REPOSITORY}" \ --ref "${GITHUB_REF}" \ diff --git a/.github/workflows/update_builds_txt.yaml b/.github/workflows/update_builds_txt.yaml index 05a5bb1b718..1c991fd0d35 100644 --- a/.github/workflows/update_builds_txt.yaml +++ b/.github/workflows/update_builds_txt.yaml @@ -47,12 +47,18 @@ jobs: GIT_AUTHOR_EMAIL="${{ github.actor }}@users.noreply.github.com" \ GIT_COMMITTER_NAME="github-actions[bot]" \ GIT_COMMITTER_EMAIL="github-actions[bot]@users.noreply.github.com" \ - git commit -m "Add ${{ env.OTP_REF_NAME }} to ${{ env.BUILDS_TXT }}" + git commit -m "${{ env.BUILDS_TXT }}: Add ${{ env.OTP_REF_NAME }}" git push origin $target_branch } - url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${OTP_REF_NAME}/${TGZ}" - curl --fail -LO "${url}" + if [[ "${OTP_REF_NAME}" == master ]] || [[ "${OTP_REF_NAME}" == maint* ]]; then + ref_name="${OTP_REF_NAME}-latest" + else + ref_name="${OTP_REF_NAME}" + fi + url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${ref_name}/${TGZ}" + echo downloading $url + curl -fsSLO "${url}" max_retries=5 attempt=0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..ceeb05b4108 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/tmp diff --git a/README.md b/README.md index d77fb02ffef..6170f5f2e89 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,36 @@ Supported architectures: * `amd64` * `arm64` +The goal of these builds is to be as self-contained as possible. OpenSSL (used +by `crypto` app) and wxWidgets (used by `wx` app and it's dependants, +`observer`, `debugger`, and `et`) are statically linked. + ## List of Builds +| Target | OpenSSL | wxWidgets | +| --------------------------- | ------- | ------------------------- | +| **OTP 25** | | | +| `macos-amd64` | 3.1.6 | N/A 2 | +| `macos-arm64` 1 | 3.1.6 | N/A 2 | +| **OTP 26** | | | +| `macos-amd64` | 3.1.6 | N/A 2 / 3.2.5 | +| `macos-arm64` | 3.1.6 | N/A 2 / 3.2.5 | +| **OTP 27** | | | +| `macos-amd64` | 3.1.6 | 3.2.5 | +| `macos-arm64` | 3.1.6 | 3.2.5 | +| **OTP maint** 3 | | | +| `macos-amd64` | 3.1.6 | 3.2.5 | +| `macos-arm64` | 3.1.6 | 3.2.5 | +| **OTP master** 3 | | | +| `macos-amd64` | 3.1.6 | 3.2.5 | +| `macos-arm64` | 3.1.6 | 3.2.5 | + +1 JIT is disabled on OTP 25 on macos-arm64. + +2 `wx`, `observer`, `debugger`, and `et` apps are only available since OTP 26.1.1. + +3 OTP maint and master builds are updated daily. + List of builds can be found here: * `macos-amd64` - diff --git a/builds/macos-amd64.txt b/builds/macos-amd64.txt new file mode 100644 index 00000000000..ff451f63fac --- /dev/null +++ b/builds/macos-amd64.txt @@ -0,0 +1,8 @@ +OTP-25.0 4ed7957623e5ccbd420a09a506bd6bc9930fe93c 2024-09-23T12:33:08Z 5200889aff2b2998986db9ae42c059339ba28aae6dca034ba98d1d71ea0b6285 +OTP-26.0 8c0ea6bd3306cfd6ca19730d180a2a93a716e1ee 2024-09-23T20:55:07Z 004e5323f1add1f9086a602e7ecbf96d77aa61344e430b4da6cf53a098d00e5b +OTP-27.0 601a012837ea0a5c8095bf24223132824177124d 2024-09-17T12:12:46Z 00da31f072aaf51e54c8969af1b68967e9b3836fe84fee8602b3f69f9f5033e6 +OTP-27.0-rc3 5df3992d695da4d7e8777cf7605279ce9d131f1c 2024-09-19T20:37:41Z 304877513c3c03b93ac6ba78e9bcf25f0289673772c3778373a0b1a2d91efe17 +OTP-27.0.1 ee9628e7ed09ef02e767994a6da5b7a225316aaa 2024-09-17T08:28:27Z f3adb7a52341fc20a8e886a851e18e251e5b88ff33a621c4651ff7e3f574f943 +OTP-27.1 9ae2ef54fc6dacb5bfbe2dc6fc6f2522d57ce1fb 2024-09-18T13:28:34Z 2b425afca5fa1750361e4a96eb9d50fd6e1e42148c9cbb5fe28444de5c28e93d +maint 2ef18fe6b13c2c399f24bfc0f8af0fcb8c688ba5 2024-09-23T18:19:26Z fb562bd119ddb91c4af3eb302f8893c2dda566d00c68c3ba3c5ce24aed53dc5e +master 951d24a70523cda13695250a545ebd5284b29db0 2024-09-23T18:19:48Z a3b7deb0b89488006bab5c74b5e54e2857417563be3624b09ad96ca690231724 diff --git a/builds/macos-arm64.txt b/builds/macos-arm64.txt new file mode 100644 index 00000000000..2054e15b512 --- /dev/null +++ b/builds/macos-arm64.txt @@ -0,0 +1,7 @@ +OTP-25.0 4ed7957623e5ccbd420a09a506bd6bc9930fe93c 2024-09-23T12:26:37Z f94a74de35f41533d9d5b451a5b651ca789533869a846ced9c6011824a879f37 +OTP-26.0 8c0ea6bd3306cfd6ca19730d180a2a93a716e1ee 2024-09-23T20:54:52Z 2bc4747564cf6ac06d24de145964485dec16de75d6180ee58740842d2534335b +OTP-27.0 601a012837ea0a5c8095bf24223132824177124d 2024-09-17T12:12:25Z 08a007a426baa6d693c84bcd3c43f9b4eec2037fd4583a31da3f936b694765d7 +OTP-27.0-rc3 5df3992d695da4d7e8777cf7605279ce9d131f1c 2024-09-19T20:31:42Z df90b7feca41c22aa7612e1382050638c63d86211c4b95586deb1e9e43644090 +OTP-27.0.1 ee9628e7ed09ef02e767994a6da5b7a225316aaa 2024-09-17T08:28:39Z 2eea6ca2baaf8fca2b6c5577231cf0c1fedf598cf2154e4ef40e0f1e6cfa34cb +maint 2ef18fe6b13c2c399f24bfc0f8af0fcb8c688ba5 2024-09-23T18:14:26Z 09e4a7632856f8cb23d642be29d3ffa0ee7a8a630b85410f6c3c13cdac198318 +master 951d24a70523cda13695250a545ebd5284b29db0 2024-09-23T18:14:09Z db23aa8937d5e76a537a2cb6376d7b87037a9d307860b3553916cd15ddba3b01 diff --git a/scripts/build_otp_macos.bash b/scripts/build_otp_macos.bash index ca9fc299e53..71286b8ed9b 100644 --- a/scripts/build_otp_macos.bash +++ b/scripts/build_otp_macos.bash @@ -1,5 +1,5 @@ #!/bin/bash -set -euox pipefail +set -euo pipefail main() { if [ $# -ne 1 ]; then @@ -11,16 +11,29 @@ EOF fi local ref_name=$1 + + case "$ref_name" in + OTP-25* | OTP-26.0* | OTP-26.1) + WXWIDGETS_VERSION=disabled + ;; + *) + ;; + esac + + : "${BUILD_DIR:=$PWD/tmp/builds}" : "${OPENSSL_VERSION:=3.1.6}" - : "${OPENSSL_DIR:=/tmp/builds/openssl-${OPENSSL_VERSION}-macos}" + : "${OPENSSL_DIR:=$BUILD_DIR/openssl-${OPENSSL_VERSION}-macos}" : "${WXWIDGETS_VERSION:=3.2.6}" - : "${WXWIDGETS_DIR:=/tmp/builds/wxwidgets-${WXWIDGETS_VERSION}-macos}" - : "${OTP_DIR:=/tmp/builds/otp-${ref_name}-openssl-${OPENSSL_VERSION}-wxwidgets-${WXWIDGETS_VERSION}-macos}" + : "${WXWIDGETS_DIR:=$BUILD_DIR/wxwidgets-${WXWIDGETS_VERSION}-macos}" + : "${OTP_DIR:=$BUILD_DIR/otp-${ref_name}-openssl-${OPENSSL_VERSION}-wxwidgets-${WXWIDGETS_VERSION}-macos}" export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN) export CFLAGS="-Os -fno-common -mmacosx-version-min=11.0" build_openssl "${OPENSSL_VERSION}" - build_wxwidgets "${WXWIDGETS_VERSION}" + + if [ "${WXWIDGETS_VERSION}" != disabled ]; then + build_wxwidgets "${WXWIDGETS_VERSION}" + fi export PATH="${WXWIDGETS_DIR}/bin:$PATH" build_otp "${ref_name}" @@ -29,7 +42,7 @@ EOF build_openssl() { local version=$1 local rel_dir="${OPENSSL_DIR}" - local src_dir="/tmp/builds/src-openssl-${version}" + local src_dir="$BUILD_DIR/src-openssl-${version}" if [ -d "${rel_dir}/bin" ]; then echo "${rel_dir}/bin already exists, skipping build" @@ -60,7 +73,7 @@ build_openssl() { build_wxwidgets() { local version=$1 local rel_dir="${WXWIDGETS_DIR}" - local src_dir="/tmp/builds/src-wxwidgets-${version}" + local src_dir="$BUILD_DIR/src-wxwidgets-${version}" if [ -d "${rel_dir}/bin" ]; then echo "${rel_dir}/bin already exists, skipping build" @@ -69,7 +82,7 @@ build_wxwidgets() { fi if [ ! -d ${src_dir} ]; then - curl --fail -LO https://github.com/wxWidgets/wxWidgets/releases/download/v$version/wxWidgets-$version.tar.bz2 + curl -fsSLO https://github.com/wxWidgets/wxWidgets/releases/download/v$version/wxWidgets-$version.tar.bz2 tar -xf wxWidgets-$version.tar.bz2 mv wxWidgets-$version $src_dir rm wxWidgets-$version.tar.bz2 @@ -92,22 +105,32 @@ build_wxwidgets() { fi } +test_otp() { + erl -noshell -eval 'io:format("~s~s~n", [ + erlang:system_info(system_version), + erlang:system_info(system_architecture)]), + ok = crypto:start(), io:format("crypto ok~n"), + halt().' + + if [ "${WXWIDGETS_VERSION}" != disabled ]; then + erl -noshell -eval ' + wx:new(), io:format("wx ok~n"), + halt().' + else + echo wx disabled + fi +} + build_otp() { local ref_name="$1" local rel_dir="${OTP_DIR}" - local src_dir="/tmp/builds/src-otp-${ref_name}" + local src_dir="$BUILD_DIR/src-otp-${ref_name}" local wx_test - local test_cmd="erl -noshell -eval 'io:format(\"~s~s~n\", [ - erlang:system_info(system_version), - erlang:system_info(system_architecture)]), - ok = crypto:start(), io:format(\"crypto ok~n\"), - wx:new(), io:format(\"wx ok~n\"), - halt().'" - if [ -d "${rel_dir}/bin" ]; then echo "${rel_dir}/bin already exists, skipping build" - eval ${rel_dir}/bin/${test_cmd} + export PATH="${rel_dir}/bin:$PATH" + test_otp return fi @@ -123,9 +146,27 @@ build_otp() { export ERL_TOP=$PWD export ERLC_USE_SERVER=true + if [ "$(uname -m)" = "arm64" ]; then + if echo "$ref_name" | grep -q "^OTP-25"; then + jit_flags="--disable-jit" + else + jit_flags="" + fi + else + jit_flags="" + fi + + if [ "${WXWIDGETS_VERSION}" = disabled ]; then + wxwidgets_flags=--without-{wx,observer,debugger,et} + else + wxwidgets_flags="" + fi + ./otp_build configure \ --with-ssl=${OPENSSL_DIR} \ - --disable-dynamic-ssl-lib + --disable-dynamic-ssl-lib \ + $jit_flags \ + $wxwidgets_flags ./otp_build boot -a ./otp_build release -a ${rel_dir} @@ -136,7 +177,8 @@ build_otp() { rm Install ) - if ! eval ${rel_dir}/bin/erl ${test_cmd}; then + export PATH="${rel_dir}/bin:$PATH" + if ! test_otp; then rm -rf ${rel_dir} fi }