diff --git a/.github/workflows/docker-cron.yml b/.github/workflows/docker-cron.yml index 8813d6b..2b4b3c4 100644 --- a/.github/workflows/docker-cron.yml +++ b/.github/workflows/docker-cron.yml @@ -18,7 +18,7 @@ jobs: - name: Build the WireGuard binary (wireguard-go) run: | cat build-wg-go.sh | docker run --rm -i -v="$PWD/workspace:/workspace" -w="/workspace" golang:latest sh - ls ./workspace/wireguard-go + ls ./workspace/wireguard-go* - name: Get version id: getver run: echo "::set-output name=body::`./workspace/wireguard-go --version | head -n 1 | cut -d ' ' -f 2`" @@ -30,16 +30,27 @@ jobs: with: tag_name: ${{ steps.getver.outputs.body }} release_name: Release ${{ steps.getver.outputs.body }} - body: Binary build for Linux system with amd64 architecture. + body: Binary build of WireGuard written in Golang. draft: false prerelease: false - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + id: upload-release-asset + uses: actions/github-script@v3 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./workspace/wireguard-go - asset_name: wireguard-go - asset_content_type: application/octet-stream + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const path = require('path'); + const fs = require('fs'); + const release_id = '${{ steps.create_release.outputs.id }}'; + for (let file of await fs.readdirSync('./workspace/')) { + if (file.startsWith("wireguard-go")) { + console.log('uploadReleaseAsset', file); + await github.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release_id, + name: file, + data: await fs.readFileSync(`./workspace/${file}`) + }); + } + } diff --git a/.github/workflows/docker-dev.yml b/.github/workflows/docker-dev.yml index 80a9101..c445656 100644 --- a/.github/workflows/docker-dev.yml +++ b/.github/workflows/docker-dev.yml @@ -20,7 +20,7 @@ jobs: - name: Build the WireGuard binary (wireguard-go) run: | cat build-wg-go.sh | docker run --rm -i -v="$PWD/workspace:/workspace" -w="/workspace" golang:latest sh - ls ./workspace/wireguard-go + ls ./workspace/wireguard-go* - name: Get version id: getver run: ./workspace/wireguard-go --version | head -n 1 | cut -d ' ' -f 2 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ef8ce10..f08b2c7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -20,7 +20,7 @@ jobs: - name: Build the WireGuard binary (wireguard-go) run: | cat build-wg-go.sh | docker run --rm -i -v="$PWD/workspace:/workspace" -w="/workspace" golang:latest sh - ls ./workspace/wireguard-go + ls ./workspace/wireguard-go* - name: Get version id: getver run: echo "::set-output name=body::`./workspace/wireguard-go --version | head -n 1 | cut -d ' ' -f 2`" @@ -32,16 +32,27 @@ jobs: with: tag_name: ${{ steps.getver.outputs.body }} release_name: Release ${{ steps.getver.outputs.body }} - body: Binary build for Linux system with amd64 architecture. - draft: false + body: Binary build of WireGuard written in Golang. + draft: true prerelease: false - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + id: upload-release-asset + uses: actions/github-script@v3 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./workspace/wireguard-go - asset_name: wireguard-go - asset_content_type: application/octet-stream + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const path = require('path'); + const fs = require('fs'); + const release_id = '${{ steps.create_release.outputs.id }}'; + for (let file of await fs.readdirSync('./workspace/')) { + if (file.startsWith("wireguard-go")) { + console.log('uploadReleaseAsset', file); + await github.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release_id, + name: file, + data: await fs.readFileSync(`./workspace/${file}`) + }); + } + } diff --git a/README.md b/README.md index bd2eb50..be7fe4c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # wg-go-builder -Build WireGuard for linux-amd64 from source: https://github.com/WireGuard/wireguard-go. +Build WireGuard for linux-amd64 (and other supported platforms, not tested) from source: https://github.com/WireGuard/wireguard-go. -This repository contains a bash script for compiling the `wireguard-go` binary from source. With this binary, users are able to create WireGuard sessions without installing the kernel module version (if not preloaded for Linux Kernel 5.6 and above). +This repository contains a bash script that compiles the `wireguard-go` binary from source. With this binary, Linux users are able to create WireGuard sessions without installing the kernel module version (if not preloaded for Linux Kernel 5.6 and above). Instructions for compiling are availablie here: https://github.com/WireGuard/wireguard-go#building diff --git a/build-wg-go.sh b/build-wg-go.sh index cb3bb9e..e9ca626 100644 --- a/build-wg-go.sh +++ b/build-wg-go.sh @@ -7,8 +7,14 @@ set -e # Initialise build environment GOPATH=`pwd` go get -v -d golang.zx2c4.com/wireguard +# Define build configurations +OSARCHCFG="linux:amd64:wireguard-go windows:amd64:wireguard-go.exe darwin:amd64:wireguard-go-darwin linux:arm64:wireguard-go-linux-arm64" + # Build OLD_PATH=`pwd` NEW_PATH=`dirname $(find . -type f -name "go.mod" | grep "wireguard")` cd ${NEW_PATH} -GOPATH=${OLD_PATH} GOOS=linux GOARCH=amd64 go build -v -o "${OLD_PATH}/wireguard-go" +for CFG in ${OSARCHCFG} +do + GOOS=`echo ${CFG} | cut -d ':' -f 1` GOARCH=`echo ${CFG} | cut -d ':' -f 2` GOPATH=${OLD_PATH} go build -v -o "${OLD_PATH}/`echo ${CFG} | cut -d ':' -f 3`" +done