|
| 1 | +name: Upload Release Asset |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +env: |
| 9 | + GO_VERSION: "1.15" |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Get the target release version |
| 16 | + id: get_version |
| 17 | + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} |
| 18 | + |
| 19 | + - name: Set up Go ${{ env.GO_VERSION }} |
| 20 | + uses: actions/setup-go@v2 |
| 21 | + with: |
| 22 | + go-version: ^${{ env.GO_VERSION }} |
| 23 | + id: go |
| 24 | + |
| 25 | + - name: Check out code into the Go module directory |
| 26 | + uses: actions/checkout@v2 |
| 27 | + |
| 28 | + - name: Build |
| 29 | + run: | |
| 30 | + mkdir -p bin |
| 31 | + VERSION=${{ steps.get_version.outputs.VERSION }} |
| 32 | + STATIC_FLAG='-w -extldflags "-static"' |
| 33 | + for platform in darwin/amd64 linux/amd64 linux/ppc64le |
| 34 | + do |
| 35 | + os_name=$(echo "$platform" | cut -d "/" -f 1) |
| 36 | + arch=$(echo "$platform" | cut -d "/" -f 2) |
| 37 | + 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} . |
| 38 | + done |
| 39 | + tar -czvf pvsadm-binaries.tar.gz bin/ |
| 40 | +
|
| 41 | + - name: Create Release |
| 42 | + id: create_release |
| 43 | + uses: actions/create-release@v1 |
| 44 | + env: |
| 45 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + with: |
| 47 | + tag_name: ${{ github.ref }} |
| 48 | + release_name: Release ${{ steps.get_version.outputs.VERSION }} |
| 49 | + draft: true |
| 50 | + prerelease: true |
| 51 | + |
| 52 | + - name: Upload linux - amd64 |
| 53 | + uses: actions/upload-release-asset@v1 |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + with: |
| 57 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 58 | + asset_path: ./bin/pvsadm-linux-amd64 |
| 59 | + asset_name: pvsadm-linux-amd64 |
| 60 | + asset_content_type: application/octet-stream |
| 61 | + |
| 62 | + - name: Upload linux - ppc64le |
| 63 | + uses: actions/upload-release-asset@v1 |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + with: |
| 67 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 68 | + asset_path: ./bin/pvsadm-linux-ppc64le |
| 69 | + asset_name: pvsadm-linux-ppc64le |
| 70 | + asset_content_type: application/octet-stream |
| 71 | + |
| 72 | + - name: Upload macos |
| 73 | + uses: actions/upload-release-asset@v1 |
| 74 | + env: |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + with: |
| 77 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 78 | + asset_path: ./bin/pvsadm-darwin-amd64 |
| 79 | + asset_name: pvsadm-darwin-amd64 |
| 80 | + asset_content_type: application/octet-stream |
| 81 | + |
| 82 | + - name: Upload all |
| 83 | + uses: actions/upload-release-asset@v1 |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + with: |
| 87 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 88 | + asset_path: pvsadm-binaries.tar.gz |
| 89 | + asset_name: pvsadm-binaries.tar.gz |
| 90 | + asset_content_type: application/tar+gzip |
0 commit comments