From 0f08fe42aa57477342cf484ed7bec2e11dc93bbf Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sat, 18 Nov 2023 14:06:10 -0600 Subject: [PATCH] more building improvements on MacOS --- .github/workflows/onyx-build.yml | 105 ++++++++++++++++++++++++++++--- bin/install.sh | 3 +- build.bat | 3 + build.sh | 16 +++++ 4 files changed, 119 insertions(+), 8 deletions(-) diff --git a/.github/workflows/onyx-build.yml b/.github/workflows/onyx-build.yml index 0a5fe71c..0cdd80e3 100644 --- a/.github/workflows/onyx-build.yml +++ b/.github/workflows/onyx-build.yml @@ -14,9 +14,28 @@ on: description: 'Make release' jobs: + setup: + name: Set up + runs-on: ubuntu-latest + outputs: + VERSION: ${{ steps.setup.outputs.VERSION }} + DOING_RELEASE: ${{ steps.setup.outputs.DOING_RELEASE }} + steps: + - name: Set up environment variables + id: setup + shell: bash + run: | + VERSION=${GITHUB_REF/refs\/tags\//} + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + DOING_RELEASE=$(echo $VERSION | grep -c '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+\(-\([a-zA-Z]\+\)\?[0-9]*\)\?$' || true) + echo "DOING_RELEASE=${DOING_RELEASE}" >> $GITHUB_OUTPUT + echo $VERSION + echo $DOING_RELEASE + build: name: Building on ${{ matrix.build }} runs-on: ${{ matrix.os }} + needs: [ setup ] strategy: fail-fast: false matrix: @@ -52,10 +71,9 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup directory for building - if: matrix.build == 'linux-amd64' + if: matrix.build != 'windows-amd64' run: | chmod +x build.sh - mkdir -p build - name: Install Linux building dependencies if: matrix.runtime_library == 'wasmer' @@ -70,7 +88,7 @@ jobs: - name: Build Onyx for ${{ matrix.build }} if: (matrix.build == 'linux-amd64') && (matrix.runtime_library != 'none') run: | - ./build.sh compile package + ./build.sh compile compress env: ONYX_CC: gcc ONYX_ARCH: linux_x86_64 @@ -80,7 +98,7 @@ jobs: - name: Build Onyx for ${{ matrix.build }} if: (matrix.build == 'linux-amd64') && (matrix.runtime_library == 'none') run: | - ./build.sh compile package + ./build.sh compile compress env: ONYX_CC: gcc ONYX_ARCH: linux_x86_64 @@ -88,7 +106,7 @@ jobs: - name: Build Onyx for ${{ matrix.build }} if: (matrix.build == 'darwin-amd64') && (matrix.runtime_library == 'none') run: | - ./build.sh compile package + ./build.sh compile compress env: ONYX_CC: gcc ONYX_ARCH: darwin_amd64 @@ -96,7 +114,7 @@ jobs: - name: Build Onyx for ${{ matrix.build }} if: (matrix.build == 'darwin-arm64') && (matrix.runtime_library == 'none') run: | - ./build.sh compile package + ./build.sh compile compress env: ONYX_CC: gcc ONYX_ARCH: darwin_arm64 @@ -113,4 +131,77 @@ jobs: name: ${{ matrix.artifact_name }} path: dist if-no-files-found: error - retention-days: 5 \ No newline at end of file + retention-days: 5 + + release: + needs: [setup, build] + runs-on: ubuntu-latest + if: needs.setup.outputs.DOING_RELEASE == '1' || github.event.inputs.release != '' + steps: + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.setup.outputs.VERSION }} + release_name: Release ${{ needs.setup.outputs.VERSION }} + draft: true + prerelease: false + + release_upload: + needs: [setup, build, release] + runs-on: ubuntu-latest + if: needs.setup.outputs.DOING_RELEASE == '1' || github.event.inputs.release != '' + strategy: + fail-fast: false + matrix: + include: + - build: linux-amd64 + artifact_name: 'onyx-linux-ovm-amd64' + asset_friendy_name: 'Linux AMD64 with OVM' + - build: linux-amd64 + artifact_name: 'onyx-linux-wasmer-amd64' + asset_friendy_name: 'Linux AMD64 with Wasmer' + - build: linux-amd64 + artifact_name: 'onyx-linux-none-amd64' + asset_friendy_name: 'Linux AMD64' + - build: darwin-arm64 + artifact_name: 'onyx-darwin-none-arm64' + asset_friendy_name: 'MacOS ARM64' + - build: darwin-amd64 + artifact_name: 'onyx-darwin-none-amd64' + asset_friendy_name: 'MacOS AMD64' + # - build: darwin-arm64 + # os: macos-11.0 + # runtime_library: wasmer + # artifact_name: 'onyx-darwin-wasmer-arm64' + - build: windows-amd64 + artifact_name: 'onyx-windows-wasmer-amd64' + asset_friendy_name: 'Windows x64' + steps: + - name: Upload Release Asset ${{ matrix.asset_friendly_name }} + if: ${{ matrix.build }} != 'windows-amd64' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/${{ matrix.artifact_name }}/onyx.tar.gz + asset_name: ${{ matrix.artifact_name }}.tar.gz + asset_content_type: application/gzip + + - name: Upload Release Asset ${{ matrix.asset_friendly_name }} + if: ${{ matrix.build }} == 'windows-amd64' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/${{ matrix.artifact_name }}/onyx.zip + asset_name: ${{ matrix.artifact_name }}.zip + diff --git a/bin/install.sh b/bin/install.sh index ea84bca8..e455993c 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -223,7 +223,6 @@ initRuntime() { } onyx_install() { - printf "${reset}Welcome to the Onyx shell installer!$reset\n" if [ "$ONYX_INSTALL_LOG" = "$ONYX_VERBOSE" ]; then printf "\033[96m ######\n" printf "\033[96m ####++++++###\n" @@ -250,6 +249,8 @@ onyx_install() { printf "\033[96m ####++++######\n" printf "\033[96m ######\n" printf "\n\n" + else + printf "The Onyx Programming Language\n\n" fi onyx_download $1 && onyx_link diff --git a/build.bat b/build.bat index 4f0e4b33..47e98a36 100644 --- a/build.bat +++ b/build.bat @@ -42,4 +42,7 @@ if "%1" == "dist" ( copy onyx_runtime.dll dist\onyx_runtime.dll xcopy tests dist\tests /s /e /h /I copy onyx.exe dist\onyx.exe + + powershell Compress-Archive dist onyx.zip + move onyx.zip dist/onyx.zip ) diff --git a/build.sh b/build.sh index ce2addd9..f08a7dd8 100755 --- a/build.sh +++ b/build.sh @@ -22,6 +22,7 @@ compile_all() { } package_all() { + rm -rf "$DIST_DIR" mkdir -p "$DIST_DIR" echo "Installing on '$(uname -a)'" @@ -55,6 +56,15 @@ package_all() { cp misc/onyx-mode.el "$DIST_DIR/misc" cp misc/onyx.sublime-syntax "$DIST_DIR/misc" cp misc/vscode/onyx-0.1.8.vsix "$DIST_DIR/misc" + + cp LICENSE "$DIST_DIR/LICENSE" +} + +compress_all() { + package_all + + tar -C dist -zcvf onyx.tar.gz bin core examples include lib misc tests tools LICENSE + mv onyx.tar.gz dist/ } install_all() { @@ -63,12 +73,18 @@ install_all() { echo "Installing to $ONYX_INSTALL_DIR" mkdir -p "$ONYX_INSTALL_DIR" cp -r "$DIST_DIR/." "$ONYX_INSTALL_DIR" + + # Sign the binaries on MacOS + [ "$(uname)" = 'Darwin' ] && \ + codesign -s - "$ONYX_INSTALL_DIR/bin/onyx" && \ + codesign -s - "$ONYX_INSTALL_DIR/lib/onyx_runtime.dylib" } for arg in $@; do case "$arg" in compile) compile_all ;; package) package_all ;; + compress) compress_all ;; install) install_all ;; clean) rm -f compiler/onyx 2>/dev/null -- 2.25.1