Update Gitlab workflow

This commit is contained in:
Khanh Ngo 2020-05-21 20:48:07 +07:00
parent c8b1ca04ac
commit f05236b632
No known key found for this signature in database
GPG key ID: D5FAA6A16150E49E
2 changed files with 43 additions and 114 deletions

View file

@ -1,87 +1,46 @@
on: release on:
name: Build Release release:
types: [created]
jobs: jobs:
release-linux-386: releases-matrix:
name: release linux/386 name: Release Go Binary
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/386, darwin/amd64
goos: [linux, windows, darwin]
goarch: ["386", amd64]
steps: steps:
- uses: actions/checkout@master # get the source code
- name: compile and release - uses: actions/checkout@v2
uses: ngs/go-release.action@v1.0.1
env: # set environment
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set APP_VERSION env
GOARCH: "386" run: echo ::set-env name=APP_VERSION::$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev )
GOOS: linux - name: Set BUILD_TIME env
CMD_PATH: "-a -o wg-ui" run: echo ::set-env name=BUILD_TIME::$(date)
release-linux-amd64: - name: Environment Printer
name: release linux/amd64 uses: managedkaos/print-env@v1.0
runs-on: ubuntu-latest
steps: # execute yarn install
- uses: actions/checkout@master - uses: borales/actions-yarn@v2.0.0
- name: compile and release with:
uses: ngs/go-release.action@v1.0.1 cmd: install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Prepare aseets
GOARCH: amd64 run: |
GOOS: linux chmod +x ./prepare_assets.sh
CMD_PATH: "-a -o wg-ui" ./prepare_assets.sh
release-linux-arm:
name: release linux/386 # build and make the releases
runs-on: ubuntu-latest - uses: wangyoucao577/go-release-action@master
steps: with:
- uses: actions/checkout@master pre_command: "go get github.com/GeertJohan/go.rice/rice && rice embed-go"
- name: compile and release github_token: ${{ secrets.GITHUB_TOKEN }}
uses: ngs/go-release.action@v1.0.1 goos: ${{ matrix.goos }}
env: goarch: ${{ matrix.goarch }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} goversion: "https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz"
GOARCH: "arm" binary_name: "wireguard-ui"
GOOS: linux build_flags: -v
CMD_PATH: "-a -o wg-ui" ldflags: -X "main.appVersion=${{ env.APP_VERSION }}" -X "main.buildTime=${{ env.BUILD_TIME }}" -X main.gitCommit=${{ github.sha }} -X main.gitRef=${{ github.ref }}
release-linux-arm64:
name: release linux/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: arm64
GOOS: linux
CMD_PATH: "-a -o wg-ui"
release-darwin-amd64:
name: release darwin/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: amd64
GOOS: darwin
CMD_PATH: "-a -o wg-ui"
release-windows-386:
name: release windows/386
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: "386"
GOOS: windows
CMD_PATH: "-a -o wg-ui"
release-windows-amd64:
name: release windows/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: amd64
GOOS: windows
CMD_PATH: "-a -o wg-ui"

View file

@ -1,30 +0,0 @@
#!/bin/sh
set -eux
PROJECT_ROOT="/go/src/github.com/${GITHUB_REPOSITORY}"
mkdir -p $PROJECT_ROOT
rmdir $PROJECT_ROOT
ln -s $GITHUB_WORKSPACE $PROJECT_ROOT
cd $PROJECT_ROOT
sh ./prepare_assets.sh
go mod download
go get github.com/GeertJohan/go.rice/rice
rice embed-go
EXT=''
if [ $GOOS == 'windows' ]; then
EXT='.exe'
fi
if [ -x "./build.sh" ]; then
OUTPUT=`./build.sh "${CMD_PATH}"`
else
go build "${CMD_PATH}"
OUTPUT="${PROJECT_NAME}${EXT}"
fi
echo ${OUTPUT}