diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index d72fbfc..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: '{build}' -platform: x64 -configuration: Release -os: Visual Studio 2015 - -clone_depth: 50 -clone_folder: c:\gopath\src\github.com\cretz\tor-static - -environment: - GOPATH: c:\gopath - -install: - - set PATH=C:\msys64\usr\bin;%PATH% - - set MSYSTEM=MINGW64 - - bash -lc "pacman -Sy --noconfirm --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain git mingw-w64-i686-cmake mingw-w64-x86_64-cmake" - -before_build: - - set MSYSTEM=MINGW64 - - cd c:\gopath\src\github.com\cretz\tor-static - - git submodule update --init --recursive - -build_script: - - set MSYSTEM=MINGW64 - - bash -lc "export PATH=/mingw64/bin:$PATH && cd /c/gopath/src/github.com/cretz/tor-static && /c/go/bin/go run build.go -verbose build-all" - -test_script: - - set PATH=C:\msys64\mingw64\bin;%PATH% - - go get -u github.com/cretz/bine/tor - - cd c:\gopath\src\github.com\cretz\tor-static - - go test -v build_test.go -tor.verbose - -after_build: - - go run build.go package-libs - - cp libs.zip tor-static-windows-amd64.zip -artifacts: -- path: tor-static-windows-amd64.zip - -deploy: - description: 'New tor-static release' - provider: GitHub - auth_token: - secure: 6FeJJsz3att0ChUBBFt+Llk8vr32vvZVDbkicQfpRn0mJrome0mIPbkLbH2J5ejC - artifact: tor-static-windows-amd64.zip - draft: true - on: - branch: master - APPVEYOR_REPO_TAG: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..3dcb136 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,166 @@ +name: Build static binaries + +on: + push: + pull_request: + release: + types: [created] + +env: + GO_VERSION_SPECIFIER: '^1.20.0' + +jobs: + build: + name: Build for ${{ matrix.triple }} + runs-on: ${{ matrix.runner-os}} + strategy: + fail-fast: false + matrix: + include: + - runner-os: ubuntu-latest + triple: x86_64-unknown-linux-gnu + use-caching: true + - runner-os: macos-latest + triple: x86_64-apple-darwin + use-caching: true + - runner-os: windows-latest + triple: x86_64-pc-windows-gnu + use-caching: false + steps: + - name: install build tools [linux] + if: runner.os == 'linux' + run: sudo apt-get install build-essential libtool autopoint + - name: Install build tools [mac] + if: runner.os == 'macOS' + run: brew install libtool automake gettext + - name: Install build tools [windows] + if: runner.os == 'Windows' + uses: msys2/setup-msys2@v2 + with: + update: true + install: + base-devel + git + subversion + mercurial + libtool + automake + autoconf + automake-wrapper + mingw-w64-i686-toolchain + mingw-w64-x86_64-toolchain + mingw-w64-i686-cmake + mingw-w64-x86_64-cmake + + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION_SPECIFIER }} + - name: Compute cache key + if: matrix.use-caching + id: cache-data + run: echo "key=${{ runner.os }}-deps-$(git submodule status | sha256sum | cut -d ' ' -f1)" >> $GITHUB_OUTPUT + - name: Cache dependencies + if: matrix.use-caching + id: cache-deps + uses: actions/cache@v3 + with: + key: ${{ steps.cache-data.outputs.key }} + path: | + PROJECT_HASH + libevent + openssl + tor + xz + zlib + - name: Download dependencies + if: ${{ steps.cache-deps.outputs.cache-hit != 'true' }} + run: git submodule update --init --recursive + - name: Check if rebuild needed + if: matrix.use-caching + id: check-rebuild + run: | + hash="$(sha256sum go.sum build.go build_test.go | cut -d ' ' -f1)" + rebuild="true" + [ "$(cat PROJECT_HASH)" == "$hash" ] && rebuild="false" + echo "$hash" > PROJECT_HASH + echo "rebuild_needed=$rebuild" >> $GITHUB_OUTPUT + - name: Build dependencies + if: ${{ steps.check-rebuild.outputs.rebuild_needed != 'true' }} + run: go run build.go -verbose build-all + - name: Upload tor binary + uses: actions/upload-artifact@v3 + with: + name: tor-${{ runner.os }} + path: + tor/src/app/tor + + test: + name: Tests ${{ matrix.triple }} + needs: build + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - runner-os: ubuntu-latest + triple: x86_64-unknown-linux-gnu + use-caching: true + - runner-os: macos-latest + triple: x86_64-apple-darwin + use-caching: true + - runner-os: windows-latest + triple: x86_64-pc-windows-gnu + use-caching: false + steps: + - name: install build tools [linux] + if: runner.os == 'linux' + run: sudo apt-get install build-essential libtool autopoint + - name: Install build tools [mac] + if: runner.os == 'macOS' + run: brew install libtool automake gettext + - name: Install build tools [windows] + if: runner.os == 'Windows' + uses: msys2/setup-msys2@v2 + with: + update: true + install: + base-devel + git + subversion + mercurial + libtool + automake + autoconf + automake-wrapper + mingw-w64-i686-toolchain + mingw-w64-x86_64-toolchain + mingw-w64-i686-cmake + mingw-w64-x86_64-cmake + + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION_SPECIFIER }} + - name: Compute cache key + if: matrix.use-caching + id: cache-data + run: echo "key=${{ runner.os }}-deps-$(git submodule status | sha256sum | cut -d ' ' -f1)" >> $GITHUB_OUTPUT + - name: Cache dependencies + if: matrix.use-caching + id: cache-deps + uses: actions/cache@v3 + with: + key: ${{ steps.cache-data.outputs.key }} + path: | + libevent + openssl + tor + xz + zlib + - name: Run tests + run: go test . diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 755c9d8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: go -go: 1.11.x -sudo: false - -stages: - - name: deploy - if: branch = master - -matrix: - include: - - name: linux-amd64 - os: linux - dist: xenial - env: CGO_ENABLED=1 GOOS=linux GOARCH=amd64 - install: - - sudo apt-get install build-essential - - sudo apt-get install libtool - - sudo apt-get install autopoint - - name: darwin-amd64 - os: osx - env: CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 - install: - - brew install libtool - - brew install gettext - -before_script: - - go run build.go -verbose build-all - -script: - - go get -u github.com/cretz/bine/tor - - go test -v build_test.go -tor.verbose - -after_script: - - go run build.go package-libs - -after_success: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv libs.tar.gz tor-static-linux-amd64.tar.gz; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mv libs.tar.gz tor-static-darwin-amd64.tar.gz; fi - -deploy: - provider: releases - api_key: "${GITHUB_PAT}" - file: - - tor-static-linux-amd64.tar.gz - - tor-static-darwin-amd64.tar.gz - skip_cleanup: true - draft: true - on: - repo: cretz/tor-static - tags: true \ No newline at end of file diff --git a/build.go b/build.go index 7a3cf17..577b42b 100644 --- a/build.go +++ b/build.go @@ -83,7 +83,7 @@ func validateEnvironment() error { // Confirm it is MinGW 64 if byts, err := exec.Command("uname", "-a").CombinedOutput(); err != nil { return fmt.Errorf("This has to be run in a MSYS or MinGW shell, uname failed: %v", err) - } else if !bytes.HasPrefix(byts, []byte("MINGW64")) && !bytes.HasPrefix(byts, []byte("MSYS2")) { + } else if !bytes.HasPrefix(byts, []byte("MINGW64")) && !bytes.HasPrefix(byts, []byte("MSYS2")) && !bytes.HasPrefix(byts, []byte("MSYS_NT")) { return fmt.Errorf("This has to be run in a MSYS or MinGW64 shell, uname output: %v", string(byts)) } case "linux": diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6d48559 --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module github.com/cretz/tor-static + +go 1.20 + +require github.com/cretz/bine v0.2.0 + +require ( + golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect + golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect + golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5b169c3 --- /dev/null +++ b/go.sum @@ -0,0 +1,24 @@ +github.com/cretz/bine v0.2.0 h1:8GiDRGlTgz+o8H9DSnsl+5MeBK4HsExxgl6WgzOCuZo= +github.com/cretz/bine v0.2.0/go.mod h1:WU4o9QR9wWp8AVKtTM1XD5vUHkEqnf2vVSo6dBqbetI= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=