more building improvements on MacOS
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 18 Nov 2023 20:06:10 +0000 (14:06 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 18 Nov 2023 20:06:10 +0000 (14:06 -0600)
.github/workflows/onyx-build.yml
bin/install.sh
build.bat
build.sh

index 0a5fe71c99638a968924d816bb20bfbc58e83516..0cdd80e3593ef1e0e7c5dfed0d994ae6d27db0e2 100644 (file)
@@ -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
+
index ea84bca8e7785eb65dd4a5a2317da5676054ae63..e455993cb870c1cf52abc7227d512d3b30364fb1 100755 (executable)
@@ -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
index 4f0e4b3355425379a39a4cf6b901b669499b9dfa..47e98a361908e6f402dcb100f2f385795883aa04 100644 (file)
--- 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
 )
index ce2addd91c86ecd759658c540b77b5bd35414ff7..f08a7dd890967c0696747b729a126f156bb58a6d 100755 (executable)
--- 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