Skip to content

Commit

Permalink
Merge pull request #21 from mkumatag/release
Browse files Browse the repository at this point in the history
Github action for releasing binaries
  • Loading branch information
mkumatag authored Dec 3, 2020
2 parents f43667b + 2d856b1 commit c434c54
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Upload Release Asset

on:
push:
tags:
- 'v*'

env:
GO_VERSION: "1.15"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get the target release version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ^${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build
run: |
mkdir -p bin
VERSION=${{ steps.get_version.outputs.VERSION }}
STATIC_FLAG='-w -extldflags "-static"'
for platform in darwin/amd64 linux/amd64 linux/ppc64le
do
os_name=$(echo "$platform" | cut -d "/" -f 1)
arch=$(echo "$platform" | cut -d "/" -f 2)
CGO_ENABLED=0 GOOS=${os_name} GOARCH=${arch} go build -a -tags netgo -ldflags "-X github.com/ppc64le-cloud/pvsadm/pkg/version.Version=${VERSION} ${STATIC_FLAG}" -o bin/pvsadm-${os_name}-${arch} .
done
tar -czvf pvsadm-binaries.tar.gz bin/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
draft: true
prerelease: true

- name: Upload linux - amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/pvsadm-linux-amd64
asset_name: pvsadm-linux-amd64
asset_content_type: application/octet-stream

- name: Upload linux - ppc64le
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/pvsadm-linux-ppc64le
asset_name: pvsadm-linux-ppc64le
asset_content_type: application/octet-stream

- name: Upload macos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/pvsadm-darwin-amd64
asset_name: pvsadm-darwin-amd64
asset_content_type: application/octet-stream

- name: Upload all
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: pvsadm-binaries.tar.gz
asset_name: pvsadm-binaries.tar.gz
asset_content_type: application/tar+gzip

0 comments on commit c434c54

Please sign in to comment.