From 8ed84195847bb2dcb8cc896de30ff398fcad2df1 Mon Sep 17 00:00:00 2001 From: Wade Simmons Date: Sat, 21 Dec 2019 01:15:41 -0500 Subject: [PATCH] GitHub Action: add release script (#124) This script will be triggered by any tag starting with `v[0-9]+.[0-9]+.[0-9]+` (i.e. v1.1.0). It will create all of the .tar.gz files (or .zip for windows). The amd64 binaries will be compiled on their target systems, the rest of the Linux architecures will be cross compiled from the Linux amd64 host. A SHASUM256.txt will also be generated and attached to the release. --- .github/workflows/release.yml | 280 ++++++++++++++++++++++++++++++++++ Makefile | 8 +- 2 files changed, 286 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..052488f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,280 @@ +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]*' + +name: Create release and upload binaries + +jobs: + build-linux: + name: Build Linux All + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + run: | + make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" release-linux + mkdir release + mv build/*.tar.gz release + + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: linux-latest + path: release + + build-windows: + name: Build Windows amd64 + runs-on: windows-latest + steps: + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + run: | + echo $Env:GITHUB_REF.Substring(11) + go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\nebula.exe ./cmd/nebula-service + go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\nebula-cert.exe ./cmd/nebula-cert + + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: windows-latest + path: build + + build-darwin: + name: Build Darwin amd64 + runs-on: macOS-latest + steps: + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + run: | + make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" service build/nebula-darwin-amd64.tar.gz + mkdir release + mv build/*.tar.gz release + + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: darwin-latest + path: release + + release: + name: Create and Upload Release + needs: [build-linux, build-darwin, build-windows] + runs-on: ubuntu-latest + steps: + - name: Download Linux artifacts + uses: actions/download-artifact@v1 + with: + name: linux-latest + + - name: Download Darwin artifacts + uses: actions/download-artifact@v1 + with: + name: darwin-latest + + - name: Download Windows artifacts + uses: actions/download-artifact@v1 + with: + name: windows-latest + + - name: Zip Windows + run: | + cd windows-latest + zip nebula-windows-amd64.zip nebula.exe nebula-cert.exe + + - name: Create sha256sum + run: | + for dir in linux-latest darwin-latest windows-latest + do + ( + cd $dir + if [ "$dir" = windows-latest ] + then + sha256sum