├── .github └── workflows │ ├── build_and_release.yml │ └── update-check.yml ├── COPYING ├── README.md └── build.sh /.github/workflows/build_and_release.yml: -------------------------------------------------------------------------------- 1 | name: Build and Release 2 | 3 | on: 4 | repository_dispatch: 5 | workflow_dispatch: 6 | inputs: 7 | wggo_version: 8 | description: 'wireguard-go version' 9 | required: false 10 | go_version: 11 | description: 'go environment version' 12 | required: false 13 | release: 14 | description: 'Upload to Release' 15 | type: boolean 16 | required: true 17 | default: false 18 | 19 | permissions: 20 | contents: write 21 | 22 | jobs: 23 | build: 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | 28 | - name: Get Version Number 29 | run: | 30 | if [[ -n "${{ github.event.inputs.wggo_version }}" ]]; then 31 | WGGO_VERSION=${{ github.event.inputs.wggo_version }} 32 | else 33 | WGGO_VERSION=$(curl -fsSL https://api.github.com/repos/WireGuard/wireguard-go/tags | grep 'name' | grep -v v | head -1 | cut -d'"' -f4) 34 | fi 35 | echo "WGGO_VERSION=${WGGO_VERSION}" >> $GITHUB_ENV 36 | 37 | - name: Checkout 38 | uses: actions/checkout@v2 39 | 40 | - name: Setup go 41 | if: github.event.inputs.go_version == '' 42 | uses: actions/setup-go@v3 43 | with: 44 | go-version: '>=1.18' 45 | check-latest: true 46 | 47 | - name: Setup go (target version) 48 | if: github.event.inputs.go_version != '' 49 | uses: actions/setup-go@v3 50 | with: 51 | go-version: ${{ github.event.inputs.go_version }} 52 | check-latest: true 53 | 54 | - name: Build 55 | run: ./build.sh 56 | 57 | - name: Upload Artifact 58 | uses: actions/upload-artifact@v2 59 | with: 60 | name: wireguard-go-${{ env.WGGO_VERSION }} 61 | path: build 62 | 63 | - name: Upload to Release 64 | if: contains(github.event.action, 'Bump') || github.event.inputs.release == 'true' 65 | uses: svenstaro/upload-release-action@v2 66 | with: 67 | repo_token: ${{ github.token }} 68 | file: build/* 69 | tag: ${{ env.WGGO_VERSION }} 70 | overwrite: true 71 | file_glob: true 72 | prerelease: false 73 | body: "Change logs: https://git.zx2c4.com/wireguard-go/log" 74 | -------------------------------------------------------------------------------- /.github/workflows/update-check.yml: -------------------------------------------------------------------------------- 1 | name: Update Check 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: 45 12 * * * 7 | 8 | permissions: 9 | actions: write 10 | contents: write 11 | 12 | jobs: 13 | check: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | 18 | - name: Get Version Number 19 | id: getVersion 20 | run: echo "releaseTag=$(curl -fsSL https://api.github.com/repos/WireGuard/wireguard-go/tags | grep 'name' | grep -v v | head -1 | cut -d'"' -f4)" >> $GITHUB_OUTPUT 21 | 22 | - name: Compare Version Number 23 | id: cacheVersion 24 | uses: actions/cache@v3 25 | with: 26 | path: .releaseTag 27 | key: wireguard-go-${{ steps.getVersion.outputs.releaseTag }} 28 | 29 | - name: Save New Version Number 30 | if: steps.cacheVersion.outputs.cache-hit != 'true' 31 | run: echo ${{ steps.getVersion.outputs.releaseTag }} | tee .releaseTag 32 | 33 | - name: Bump Version 34 | if: steps.cacheVersion.outputs.cache-hit != 'true' 35 | uses: peter-evans/repository-dispatch@v2 36 | with: 37 | token: ${{ github.token }} 38 | event-type: Bump Version to ${{ steps.getVersion.outputs.releaseTag }} 39 | 40 | - name: Delete workflow runs 41 | uses: Mattraks/delete-workflow-runs@v2 42 | with: 43 | token: ${{ github.token }} 44 | repository: ${{ github.repository }} 45 | retain_days: 0 46 | keep_minimum_runs: 1 47 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy of 2 | this software and associated documentation files (the "Software"), to deal in 3 | the Software without restriction, including without limitation the rights to 4 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 5 | of the Software, and to permit persons to whom the Software is furnished to do 6 | so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all 9 | copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wireguard-go-builder 2 | 3 | Compiling the [wireguard-go](https://git.zx2c4.com/wireguard-go/) binary from source. With this binary, users are able to create WireGuard sessions without installing the kernel module (if not preloaded for Linux Kernel 5.6 and above). 4 | 5 | ## Download 6 | 7 | The latest version of the binary can be downloaded by clicking on the following link. 8 | 9 | [![GitHub release (latest by date)](https://img.shields.io/github/v/release/P3TERX/wireguard-go-builder?style=for-the-badge&label=Download)](https://github.com/P3TERX/wireguard-go-builder/releases/latest) 10 | 11 | ## Install 12 | 13 | You can easily use a one-click script to automatically install to your Linux device: 14 | 15 | ``` 16 | curl -fsSL git.io/wireguard-go.sh | sudo bash 17 | ``` 18 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # ref: https://github.com/AlexanderOMara/wireguard-go-builds/blob/master/build.sh 3 | 4 | set -e 5 | set -u 6 | 7 | version="${WGGO_VERSION}" 8 | 9 | src_file="wireguard-go-${version}.tar.xz" 10 | src_url="https://git.zx2c4.com/wireguard-go/snapshot/${src_file}" 11 | 12 | base_dir="$PWD" 13 | vendor_dir="$base_dir/vendor" 14 | src_dir="$base_dir/src" 15 | build_dir="$base_dir/build" 16 | src_file_path="$vendor_dir/$src_file" 17 | 18 | # Remove existing build directories (add write access to src directories to avoid permission issues). 19 | chmod -R u+w "$src_dir" || true 20 | rm -rf "$vendor_dir" "$src_dir" "$build_dir" 21 | mkdir "$vendor_dir" "$src_dir" "$build_dir" 22 | 23 | # Get and verify extract source file. 24 | wget -O "$src_file_path" "$src_url" 25 | tar --strip-components=1 -C "$src_dir" -xJf "$src_file_path" 26 | 27 | # Patch Makefile to remove building on Linux check. 28 | sed -i.bak 's/$(wildcard .git),linux/$(wildcard .git),linux_check_disabled/g' "$src_dir/Makefile" 29 | 30 | # Build all the targets. 31 | targets=( 32 | 'darwin amd64' 33 | 34 | 'linux 386' 35 | 'linux amd64' 36 | 'linux arm' 37 | 'linux arm64' 38 | 'linux ppc64' 39 | 'linux ppc64le' 40 | 'linux mips' 41 | 'linux mipsle' 42 | 43 | 'freebsd 386' 44 | 'freebsd amd64' 45 | 'freebsd arm' 46 | 47 | 'openbsd amd64' 48 | ) 49 | for target in "${targets[@]}"; do 50 | target_=($target) 51 | target_os="${target_[0]}" 52 | target_arch="${target_[1]}" 53 | build_archive_file="wireguard-go-$target_os-$target_arch.tar.gz" 54 | build_archive_path="$build_dir/$build_archive_file" 55 | build_archive_file_sha256="$build_archive_file.sha256" 56 | 57 | echo '------------------------------------------------------------' 58 | echo "Building: $target_os $target_arch" 59 | echo '------------------------------------------------------------' 60 | 61 | export GOOS="$target_os" 62 | export GOARCH="$target_arch" 63 | export CGO_ENABLED=0 64 | 65 | pushd "$src_dir" > /dev/null 66 | make 67 | tar cfz "$build_archive_path" wireguard-go* 68 | 69 | pushd "$build_dir" > /dev/null 70 | shasum -a 256 "$build_archive_file" > "$build_archive_file_sha256" 71 | cat "$build_archive_file_sha256" 72 | popd > /dev/null 73 | 74 | make clean 75 | 76 | popd > /dev/null 77 | done 78 | --------------------------------------------------------------------------------