From 7d236793d9a7f27c4ed2512cf7aa887f9a8ad280 Mon Sep 17 00:00:00 2001 From: Claudson Oliveira Date: Sun, 27 Oct 2019 09:26:10 +0000 Subject: [PATCH] Add support to static binaries (windows/linux amd64) (#87) * Build for windows on github actions * Generate artifacts after build --- .github/workflows/ci.yml | 44 +++++++++++++++++++++++++++++++++++++++- README.md | 20 ++++++++++++++---- install.sh | 4 ++-- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05f5483..8688f97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,11 @@ jobs: run: | make build ./gitql -v + - uses: actions/upload-artifact@master + name: Generating artifact + with: + name: gitql-linux64 + path: ./gitql build-mac: name: Build mac @@ -56,4 +61,41 @@ jobs: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(PWD)/libgit2/install/lib export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(PWD)/libgit2/install/lib make build-dynamic || true - ./gitql -v \ No newline at end of file + ./gitql -v + - uses: actions/upload-artifact@master + name: Generating artifact + with: + name: gitql-mac64 + path: ./gitql + + build-windows: + name: Build windows + runs-on: windows-2019 + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Run tests + run: | + make test + + - name: Build windows + env: + TARGET_OS_ARCH: windows/amd64 + run: | + choco install ninja vcredist2017 + set PATH=%HOMEDRIVE%\mingw64\bin;%PATH% + make build + .\gitql.exe -v + + - uses: actions/upload-artifact@master + name: Generating artifact + with: + name: gitql-win64 + path: .\gitql.exe \ No newline at end of file diff --git a/README.md b/README.md index 839f397..cb25293 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,12 @@ See more [here](https://asciinema.org/a/97094) - pkg-config ## How to install + +We support static compiling for linux and windows platform (amd64), so you can access the [releases page](https://github.com/cloudson/gitql/releases) and just grab the binary. If you want to compile itself follow the instructions below: + ### linux/amd64 -We support static compiling for linux architetures, so you can access the [releases page](https://github.com/cloudson/gitql/releases). If you want to compile itself, take a look in the dockerfile to -understand the whole process. +Read the dockerfile to understand the whole process. ### darwin/amd64 @@ -32,8 +34,18 @@ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(PWD)/libgit2/install/lib make build-dynamic ``` +### windows/amd64 + +You need a C compiler, Cmake and Ninja installed. Using chocolately it should be easy + +```bash +choco install cmake ninja vcredist2017 +set PATH=%HOMEDRIVE%\mingw64\bin;%PATH% +make build +``` + You can always take a look in our [github actions file](./.github/workflows/ci.yml) to understand -how we build it in the ci server. +how we build it in the ci server. If even after try [the binaries](https://github.com/cloudson/gitql/releases) or either compile yourself you couldn't use that. Open an issue. ## Examples @@ -66,7 +78,7 @@ As an example, this is the `commits` table: ## Questions? -`gitql -h` or open an [issue](https://github.com/cloudson/gitql/issues) +`gitql` or open an [issue](https://github.com/cloudson/gitql/issues) Notes: * Gitql doesn't want to _kill_ `git log` - it was created just for science! :sweat_smile: diff --git a/install.sh b/install.sh index fa4caea..3bbfcab 100755 --- a/install.sh +++ b/install.sh @@ -71,7 +71,6 @@ build_libgit2_windows(){ -DUSE_ICONV=OFF \ -DWINHTTP=OFF \ -DCMAKE_SYSTEM_NAME=Windows \ - -DCMAKE_C_COMPILER=${CC} \ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ -DCMAKE_INSTALL_PREFIX="${LIBGIT2_STATIC_PREFIX}" \ -DWIN32=ON \ @@ -123,7 +122,8 @@ build_libgit2(){ build_libgit2_darwin ;; windows/amd64*) - export GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-clang + export GOOS=windows GOARCH=amd64 + # CC=x86_64-w64-mingw32-clang FLAGS="-lws2_32" export CGO_LDFLAGS="${LIBGIT2_STATIC_PREFIX}/lib/libgit2.a -L${LIBGIT2_STATIC_PREFIX}/include ${FLAGS}" build_libgit2_windows