Skip to content

Commit

Permalink
Create more builds for different platform (#5)
Browse files Browse the repository at this point in the history
Build binaries for Windows (amd64),  MacOS (amd64) and Linux (arm64) in addition to Linux (amd64)
  • Loading branch information
bernardkkt authored Nov 28, 2021
1 parent 8cca40b commit ef239bd
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 25 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/docker-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
Expand All @@ -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}`)
});
}
}
2 changes: 1 addition & 1 deletion .github/workflows/docker-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 22 additions & 11 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
Expand All @@ -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}`)
});
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 7 additions & 1 deletion build-wg-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ef239bd

Please sign in to comment.