From 81d3d955b0410e69fba52aff9dd055149671773c Mon Sep 17 00:00:00 2001 From: Artyom Pervukhin Date: Fri, 20 Dec 2019 20:43:04 +0300 Subject: [PATCH] Add Github workflow to create releases with prebuilt binary --- .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) 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..dc8bfa8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Create release +on: + push: + tags: + - v* + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v1 + with: + go-version: '1.13.x' + - uses: actions/checkout@v1 + - name: Get dependencies + run: go mod download + - name: Install redis + run: sudo apt-get install -y -qq redis-server + - name: Run tests + run: go test -v -race ./... + - name: Build and archive + run: | + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build \ + -trimpath -ldflags="-s -w -X=main.explicitVersion=${GITHUB_REF##*/}" -o bitmapist-server + GZIP=-9 tar czvf bitmapist-server-linux-amd64.tar.gz bitmapist-server + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + - name: Upload artifact + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./bitmapist-server-linux-amd64.tar.gz + asset_name: bitmapist-server-linux-amd64.tar.gz + asset_content_type: application/gzip