-
Notifications
You must be signed in to change notification settings - Fork 6
74 lines (72 loc) · 2.3 KB
/
release.yml
File metadata and controls
74 lines (72 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: release
on:
push:
tags: ["v*.*.*"]
jobs:
get-tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.vars.outputs.tag }}
steps:
- uses: actions/checkout@v2
- id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
build:
env:
BIN_NAME: ${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}
needs: [get-tag]
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- { goos: darwin, goarch: amd64 }
- { goos: linux, goarch: amd64 }
- { goos: windows, goarch: amd64 }
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v1
with:
go-version: ^1.0
- name: Set binary name
id: binary_name
run: |
echo "BIN_NAME=gcppromd-${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}" >> $GITHUB_ENV
- run: >-
CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }}
GOARCH=${{ matrix.platform.goarch }}
go build -ldflags "-s -w" -o ${{ env.BIN_NAME }} ./cmd/gcppromd &&
shasum -a 256 ${{ env.BIN_NAME }} > ${{ env.BIN_NAME }}.sha256
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: binary.${{ env.BIN_NAME }}
path: |
${{ env.BIN_NAME }}
${{ env.BIN_NAME }}.sha256
if-no-files-found: error
release:
needs: [get-tag, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: .
# git fetch --tags --force is required because GitHub checkout action doesn't seems to preserve the tag annotation.
- name: Retrive release message
run: |
echo 'RELEASE_MSG<<EOF' >> $GITHUB_ENV
git fetch --tags --force && git tag -l --format='%(contents)' ${{ needs.get-tag.outputs.tag }} >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
body: ${{ env.RELEASE_MSG }}
files: |
binary.*/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}