From 46e517f36f0c42d85ec3c59d8a5b0ed103ad2d60 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Nov 2024 07:36:05 +0330 Subject: [PATCH 01/13] separated workflows added workflow dispatch to all of builds added macos workflow --- .github/workflows/build-linux.yml | 31 +++++ .github/workflows/build-macos.yml | 24 ++++ .github/workflows/build-publish-docker.yml | 85 ++++++++++++++ .github/workflows/build-release.yml | 130 +++------------------ .github/workflows/build-windows.yml | 22 ++++ Tools/mssql-proxy/mssql-proxy.mac.spec | 38 ++++++ 6 files changed, 215 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/build-linux.yml create mode 100644 .github/workflows/build-macos.yml create mode 100644 .github/workflows/build-publish-docker.yml create mode 100644 .github/workflows/build-windows.yml create mode 100644 Tools/mssql-proxy/mssql-proxy.mac.spec diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml new file mode 100644 index 0000000..f2afe69 --- /dev/null +++ b/.github/workflows/build-linux.yml @@ -0,0 +1,31 @@ +name: Build Linux + +on: + workflow_call: + workflow_dispatch: + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.11.4 + - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller + - run: ./Tools/mssql-proxy/odbc-driver-installer.sh + - run: pyinstaller mssql-proxy.linux.spec + working-directory: Tools/mssql-proxy + - id: name + run: echo "platform_name=$(echo ${{ matrix.platform }} | sed 's:/:-:g')" >> $GITHUB_OUTPUT + - run: tar -czf mssql-proxy-${{ github.ref_name }}-${{ steps.name.outputs.platform_name }}.tar.gz Tools/mssql-proxy/dist + - uses: actions/upload-artifact@v4 + with: + name: build-${{ steps.name.outputs.platform_name }} + path: mssql-proxy-${{ github.ref_name }}-${{ steps.name.outputs.platform_name }}.tar.gz + \ No newline at end of file diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 0000000..ac9b9ff --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,24 @@ +name: Build MacOS + +on: + workflow_call: + workflow_dispatch: + +jobs: + build-macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.11.4 + - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller + - run: ./Tools/mssql-proxy/odbc-driver-installer.sh + - run: pyinstaller mssql-proxy.mac.spec + working-directory: Tools/mssql-proxy + - run: tar -czf mssql-proxy-${{ github.ref_name }}-macos.tar.gz Tools/mssql-proxy/dist + - uses: actions/upload-artifact@v4 + with: + name: build-macos + path: mssql-proxy-${{ github.ref_name }}-macos.tar.gz + \ No newline at end of file diff --git a/.github/workflows/build-publish-docker.yml b/.github/workflows/build-publish-docker.yml new file mode 100644 index 0000000..67aaf6d --- /dev/null +++ b/.github/workflows/build-publish-docker.yml @@ -0,0 +1,85 @@ +name: Build And Publish Docker + +on: + workflow_call: + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + publish-docker: + runs-on: ubuntu-latest + if: github.ref_type == 'tag' + needs: [build-docker] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install cosign + uses: sigstore/cosign-installer@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ needs.build-docker.outputs.tags }} + labels: ${{ needs.build-docker.outputs.labels }} + platforms: linux/amd64, linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Sign the published Docker image + env: + TAGS: ${{ needs.build-docker.outputs.tags }} + DIGEST: ${{ steps.build-and-push.outputs.digest }} + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} + + build-docker: + runs-on: ubuntu-latest + outputs: + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract Docker metadata + uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build Docker images + id: build-and-push + uses: docker/build-push-action@v6 + with: + context: . + push: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64, linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max + \ No newline at end of file diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 35674c0..0c54f70 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -12,59 +12,32 @@ permissions: id-token: write packages: write -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - jobs: publish: uses: ./.github/workflows/publish.yml if: github.ref_type == 'tag' + build-linux: + uses: ./.github/workflows/build-linux.yml + + build-windows: + uses: ./.github/workflows/build-windows.yml + + build-macos: + uses: ./.github/workflows/build-macos.yml + + build-publish-docker: + uses: ./.github/workflows/build-publish-docker.yml + needs: [publish, build-linux, build-windows, build-macos] + release: runs-on: ubuntu-latest if: github.ref_type == 'tag' - needs: [publish, build-linux, build-windows, build-docker] + needs: [build-publish-docker] steps: - name: Checkout uses: actions/checkout@v4 - # publish docker - - name: Install cosign - uses: sigstore/cosign-installer@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log into registry ${{ env.REGISTRY }} - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@v6 - with: - context: . - push: true - tags: ${{ needs.build-docker.outputs.tags }} - labels: ${{ needs.build-docker.outputs.labels }} - platforms: linux/amd64, linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Sign the published Docker image - env: - TAGS: ${{ needs.build-docker.outputs.tags }} - DIGEST: ${{ steps.build-and-push.outputs.digest }} - run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} - - # create release - run: tar -czf mssql-proxy-${{ github.ref_name }}-source.tar.gz Tools/mssql-proxy - uses: actions/download-artifact@v4 with: @@ -81,77 +54,4 @@ jobs: mssql-proxy-${{ github.ref_name }}-windows.zip mssql-proxy-${{ github.ref_name }}-linux-amd64.tar.gz mssql-proxy-${{ github.ref_name }}-linux-arm64.tar.gz - - build-linux: - runs-on: ubuntu-latest - strategy: - matrix: - platform: - - linux/amd64 - - linux/arm64 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.11.4 - - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - - run: ./Tools/mssql-proxy/odbc-driver-installer.sh - - run: pyinstaller mssql-proxy.linux.spec - working-directory: Tools/mssql-proxy - - id: name - run: echo "platform_name=$(echo ${{ matrix.platform }} | sed 's:/:-:g')" >> $GITHUB_OUTPUT - - run: tar -czf mssql-proxy-${{ github.ref_name }}-${{ steps.name.outputs.platform_name }}.tar.gz Tools/mssql-proxy/dist - - uses: actions/upload-artifact@v4 - with: - name: build-${{ steps.name.outputs.platform_name }} - path: mssql-proxy-${{ github.ref_name }}-${{ steps.name.outputs.platform_name }}.tar.gz - - build-windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.11.4 - - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - - run: pyinstaller mssql-proxy.win.spec - working-directory: Tools/mssql-proxy - - run: tar -a -c -f mssql-proxy-${{ github.ref_name }}-windows.zip Tools/mssql-proxy/dist - - uses: actions/upload-artifact@v4 - with: - name: build-windows - path: mssql-proxy-${{ github.ref_name }}-windows.zip - - # build-macos: - - build-docker: - runs-on: ubuntu-latest - outputs: - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - steps: - - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Extract Docker metadata - uses: docker/metadata-action@v5 - id: meta - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build Docker images - id: build-and-push - uses: docker/build-push-action@v6 - with: - context: . - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64, linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max + mssql-proxy-${{ github.ref_name }}-macos.tar.gz \ No newline at end of file diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 0000000..d016c77 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,22 @@ +name: Build Windows + +on: + workflow_call: + workflow_dispatch: + +jobs: + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.11.4 + - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller + - run: pyinstaller mssql-proxy.win.spec + working-directory: Tools/mssql-proxy + - run: tar -a -c -f mssql-proxy-${{ github.ref_name }}-windows.zip Tools/mssql-proxy/dist + - uses: actions/upload-artifact@v4 + with: + name: build-windows + path: mssql-proxy-${{ github.ref_name }}-windows.zip diff --git a/Tools/mssql-proxy/mssql-proxy.mac.spec b/Tools/mssql-proxy/mssql-proxy.mac.spec new file mode 100644 index 0000000..de248d1 --- /dev/null +++ b/Tools/mssql-proxy/mssql-proxy.mac.spec @@ -0,0 +1,38 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['mssql-proxy.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='mssql-proxy', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) From 0fce01d7be0346648ec3e023bd825dc5ca09a309 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Nov 2024 07:41:55 +0330 Subject: [PATCH 02/13] removed matrix from test-build workflow --- .github/workflows/build-test.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9cf35d1..8895683 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -10,17 +10,13 @@ on: jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - node: [ 20 ] - name: Node ${{ matrix.node }} sample steps: - uses: actions/checkout@v4 - name: Building rules and tests uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node }} + node-version: 20 - run: npm ci working-directory: Frontend - run: npm run test-ci From 575d821f2c7d410daa530f561e6a2a1a696f1c6f Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Nov 2024 07:43:24 +0330 Subject: [PATCH 03/13] removed bash execution from mac workflow --- .github/workflows/build-macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index ac9b9ff..7b246f0 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -13,7 +13,7 @@ jobs: with: python-version: 3.11.4 - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - - run: ./Tools/mssql-proxy/odbc-driver-installer.sh + # - run: ./Tools/mssql-proxy/odbc-driver-installer.sh - run: pyinstaller mssql-proxy.mac.spec working-directory: Tools/mssql-proxy - run: tar -czf mssql-proxy-${{ github.ref_name }}-macos.tar.gz Tools/mssql-proxy/dist From 109c10d0323c2343ea383633edc0e17b32bf27cc Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Nov 2024 08:09:26 +0330 Subject: [PATCH 04/13] added hommebrew and deps to macos --- .github/workflows/build-macos.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 7b246f0..5b94cc5 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -12,8 +12,18 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.11.4 + + - name: Install Homebrew + run: | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"   + + - name: Install XCode Command Line Tools + run: xcode-select --install + - name: Install UnixODBC and MSODBCSQL18 + run: | + brew install unixodbc unixodbc-dev msodbcsql18 + - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - # - run: ./Tools/mssql-proxy/odbc-driver-installer.sh - run: pyinstaller mssql-proxy.mac.spec working-directory: Tools/mssql-proxy - run: tar -czf mssql-proxy-${{ github.ref_name }}-macos.tar.gz Tools/mssql-proxy/dist From 449a4cd365da1f09b745043b4594e52615430a3d Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Nov 2024 08:24:29 +0330 Subject: [PATCH 05/13] removed xcode cmd --- .github/workflows/build-macos.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 5b94cc5..0c0b811 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -17,12 +17,10 @@ jobs: run: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"   - - name: Install XCode Command Line Tools - run: xcode-select --install - name: Install UnixODBC and MSODBCSQL18 run: | brew install unixodbc unixodbc-dev msodbcsql18 - + - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.mac.spec working-directory: Tools/mssql-proxy From cf8cb0719a84d5bd0ebf7756bc504b9d3fdd3793 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Nov 2024 08:49:19 +0330 Subject: [PATCH 06/13] removed unixodbc-dev --- .github/workflows/build-macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 0c0b811..e7e809a 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -19,7 +19,7 @@ jobs: - name: Install UnixODBC and MSODBCSQL18 run: | - brew install unixodbc unixodbc-dev msodbcsql18 + brew install unixodbc msodbcsql18 - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.mac.spec From f8077d0fee36813a6a814cd550f2c1639a919e1e Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Sun, 17 Nov 2024 09:05:21 +0330 Subject: [PATCH 07/13] fixed msql18odbc install --- .github/workflows/build-macos.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index e7e809a..a866e65 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -19,7 +19,11 @@ jobs: - name: Install UnixODBC and MSODBCSQL18 run: | - brew install unixodbc msodbcsql18 + brew install unixodbc + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release + brew update + HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 mssql-tools18 - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.mac.spec From d2ccb907949fc1ea1e8eeb86da7ba231b89b4d32 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Mon, 18 Nov 2024 13:01:39 +0330 Subject: [PATCH 08/13] updated mac mssql spec file --- Tools/mssql-proxy/mssql-proxy.mac.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tools/mssql-proxy/mssql-proxy.mac.spec b/Tools/mssql-proxy/mssql-proxy.mac.spec index de248d1..f622643 100644 --- a/Tools/mssql-proxy/mssql-proxy.mac.spec +++ b/Tools/mssql-proxy/mssql-proxy.mac.spec @@ -5,7 +5,9 @@ a = Analysis( ['mssql-proxy.py'], pathex=[], binaries=[], - datas=[], + datas=[ + ('/usr/local/share/msodbcsql18', 'drivers/msodbcsql18') + ], hiddenimports=[], hookspath=[], hooksconfig={}, From 0aaae56f599924a00fbcd3c9b2942553a4e463ad Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Nazari <60518834+IPdotSetAF@users.noreply.github.com> Date: Tue, 19 Nov 2024 07:58:52 +0330 Subject: [PATCH 09/13] Update build-macos.yml --- .github/workflows/build-macos.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index a866e65..67802e3 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -23,7 +23,7 @@ jobs: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release brew update - HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 mssql-tools18 + HOMEBREW_SANDBOX=1 HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 mssql-tools18 - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.mac.spec @@ -33,4 +33,4 @@ jobs: with: name: build-macos path: mssql-proxy-${{ github.ref_name }}-macos.tar.gz - \ No newline at end of file + From 706383d97d736decac39f15fd2431b0760ce8125 Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Nazari <60518834+IPdotSetAF@users.noreply.github.com> Date: Tue, 19 Nov 2024 08:03:33 +0330 Subject: [PATCH 10/13] Update mssql-proxy.mac.spec --- Tools/mssql-proxy/mssql-proxy.mac.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/mssql-proxy/mssql-proxy.mac.spec b/Tools/mssql-proxy/mssql-proxy.mac.spec index f622643..21ee38d 100644 --- a/Tools/mssql-proxy/mssql-proxy.mac.spec +++ b/Tools/mssql-proxy/mssql-proxy.mac.spec @@ -6,7 +6,7 @@ a = Analysis( pathex=[], binaries=[], datas=[ - ('/usr/local/share/msodbcsql18', 'drivers/msodbcsql18') + ('/opt/homebrew/Cellar/msodbcsql18', 'drivers/msodbcsql18') ], hiddenimports=[], hookspath=[], From b02f12b231342fa5e61da1c2e02c66b72e734bca Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Nazari <60518834+IPdotSetAF@users.noreply.github.com> Date: Tue, 19 Nov 2024 08:11:37 +0330 Subject: [PATCH 11/13] Update build-macos.yml --- .github/workflows/build-macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 67802e3..a72df1a 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -24,6 +24,7 @@ jobs: brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release brew update HOMEBREW_SANDBOX=1 HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 mssql-tools18 + ls /opt/homebrew/Cellar/msodbcsql18 - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.mac.spec From 5e46f7a2f035579fd4d9a8e37163c9ad48ffc122 Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Tue, 19 Nov 2024 20:40:54 +0330 Subject: [PATCH 12/13] modified mac build (testing) --- .github/workflows/build-macos.yml | 13 ++++--------- .github/workflows/build-release.yml | 16 ++++++++-------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index a72df1a..095879a 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -13,19 +13,14 @@ jobs: with: python-version: 3.11.4 - - name: Install Homebrew - run: | - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"   - - name: Install UnixODBC and MSODBCSQL18 run: | - brew install unixodbc /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release - brew update - HOMEBREW_SANDBOX=1 HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql18 mssql-tools18 - ls /opt/homebrew/Cellar/msodbcsql18 - + HOMEBREW_SANDBOX=1 HOMEBREW_ACCEPT_EULA=Y brew install unixodbc msodbcsql18 tree + tree /opt/homebrew/Cellar/msodbcsql18/ + cat /opt/homebrew/Cellar/msodbcsql18/18.4.1.1/odbcinst.ini + - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.mac.spec working-directory: Tools/mssql-proxy diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 0c54f70..dde51e8 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -17,23 +17,23 @@ jobs: uses: ./.github/workflows/publish.yml if: github.ref_type == 'tag' - build-linux: - uses: ./.github/workflows/build-linux.yml +# build-linux: +# uses: ./.github/workflows/build-linux.yml - build-windows: - uses: ./.github/workflows/build-windows.yml +# build-windows: +# uses: ./.github/workflows/build-windows.yml build-macos: uses: ./.github/workflows/build-macos.yml - build-publish-docker: - uses: ./.github/workflows/build-publish-docker.yml - needs: [publish, build-linux, build-windows, build-macos] +# build-publish-docker: +# uses: ./.github/workflows/build-publish-docker.yml +# needs: [publish, build-linux, build-windows, build-macos] release: runs-on: ubuntu-latest if: github.ref_type == 'tag' - needs: [build-publish-docker] +# needs: [build-publish-docker] steps: - name: Checkout uses: actions/checkout@v4 From 22ea5f410ca9aacab1d9948878ef4282710365df Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Thu, 21 Nov 2024 12:34:36 +0330 Subject: [PATCH 13/13] updated mssql-proxy to automatically find odbc driver enabled mac download button cleaned up CIs --- .github/workflows/build-linux.yml | 2 +- .github/workflows/build-macos.yml | 4 +-- .github/workflows/build-release.yml | 16 ++++----- .../app/downloads/downloads.component.html | 2 +- Tools/mssql-proxy/mssql-proxy.py | 33 ++++++++++++++----- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index f2afe69..69e4f34 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -17,8 +17,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.11.4 - - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: ./Tools/mssql-proxy/odbc-driver-installer.sh + - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.linux.spec working-directory: Tools/mssql-proxy - id: name diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 095879a..59b4d0c 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -17,9 +17,7 @@ jobs: run: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release - HOMEBREW_SANDBOX=1 HOMEBREW_ACCEPT_EULA=Y brew install unixodbc msodbcsql18 tree - tree /opt/homebrew/Cellar/msodbcsql18/ - cat /opt/homebrew/Cellar/msodbcsql18/18.4.1.1/odbcinst.ini + HOMEBREW_SANDBOX=1 HOMEBREW_ACCEPT_EULA=Y brew install unixodbc msodbcsql18 - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.mac.spec diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index dde51e8..0c54f70 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -17,23 +17,23 @@ jobs: uses: ./.github/workflows/publish.yml if: github.ref_type == 'tag' -# build-linux: -# uses: ./.github/workflows/build-linux.yml + build-linux: + uses: ./.github/workflows/build-linux.yml -# build-windows: -# uses: ./.github/workflows/build-windows.yml + build-windows: + uses: ./.github/workflows/build-windows.yml build-macos: uses: ./.github/workflows/build-macos.yml -# build-publish-docker: -# uses: ./.github/workflows/build-publish-docker.yml -# needs: [publish, build-linux, build-windows, build-macos] + build-publish-docker: + uses: ./.github/workflows/build-publish-docker.yml + needs: [publish, build-linux, build-windows, build-macos] release: runs-on: ubuntu-latest if: github.ref_type == 'tag' -# needs: [build-publish-docker] + needs: [build-publish-docker] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/Frontend/src/app/downloads/downloads.component.html b/Frontend/src/app/downloads/downloads.component.html index c44a4a6..e0ad905 100644 --- a/Frontend/src/app/downloads/downloads.component.html +++ b/Frontend/src/app/downloads/downloads.component.html @@ -14,7 +14,7 @@

MSSQl proxy server

Windows Linux - AMD64 Linux - ARM64 - Mac OS + Mac OS Python Source Code diff --git a/Tools/mssql-proxy/mssql-proxy.py b/Tools/mssql-proxy/mssql-proxy.py index 33b6b29..f01ba56 100644 --- a/Tools/mssql-proxy/mssql-proxy.py +++ b/Tools/mssql-proxy/mssql-proxy.py @@ -6,7 +6,7 @@ from pydantic import BaseModel import uvicorn from colorama import Fore, Style, init -import sys +import sys, os # Initialize colorama init(autoreset=True) @@ -73,20 +73,35 @@ def log_query(index, query): endpoint_text = f"{Fore.GREEN}execute-query{Style.RESET_ALL}" print(f"{index_text} {endpoint_text}: Executed query: {query}") +def find_file_path(file_name): + base_path = sys._MEIPASS + for root, _, files in os.walk(f"{base_path}/drivers"): + if file_name in files: + return os.path.join(root, file_name) + raise f"{file_name} NotFound." + +def find_odbc_driver_path(): + try: + with open(find_file_path("odbcinst.ini"), 'r') as file: + for line in file: + line = line.strip() + if line.startswith("Driver="): + driver_name = line.split("/")[-1].strip() + break + + return find_file_path(driver_name) + except: + print("Could not fild odbc driver internally...") + return "{SQL Server}" + # Establish a database connection and return a unique connection ID @app.post("/connect") async def connect(request: ConnectRequest): global connection_index_counter try: # Attempt to connect to the database - try: - connection = pyodbc.connect(f"Driver={{SQL Server}};Server={request.server};UID={request.username};PWD={request.password};", timeout=5) - except: - try: - base_path = sys._MEIPASS - connection = pyodbc.connect(f"Driver={base_path}/drivers/msodbcsql18/lib64/libmsodbcsql-18.4.so.1.1;Server={request.server};UID={request.username};PWD={request.password};", timeout=5) - except: - raise + driver_path = find_odbc_driver_path() + connection = pyodbc.connect(f"Driver={driver_path};Server={request.server};UID={request.username};PWD={request.password};", timeout=5) # Generate a unique ID and index for the connection connection_id = str(uuid.uuid4())