-
Notifications
You must be signed in to change notification settings - Fork 12
94 lines (79 loc) · 3.36 KB
/
go.yml
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Go
on:
push:
tags:
- 'v*'
# branches: [ v2 ]
# pull_request:
# branches: [ v2 ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.16
- name: Check out code into the Go module directory
uses: actions/checkout@v2
# - name: Check out deer-common
# uses: actions/checkout@v2
# with:
# path: ./pkg/deer-common
# repository: LanceLRQ/deer-common
- name: Get version
id: get_version
run: |
TAG=$(basename ${GITHUB_REF})
echo "::set-output name=TAG::$TAG"
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build (linux_amd64)
run: |
go mod tidy
GOOS=linux GOARCH=amd64 go build -v -ldflags "-X 'main.buildGoVersion=$(go version)' -X 'main.buildGitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(git show -s --format=%cI)' -X 'main.buildVersion=$(basename ${GITHUB_REF})'" .
- name: Pack (linux_amd64)
run: |
zip -r deer-executor-linux-amd64.zip deer-executor lib CHANGELOG COMMANDS.md README.md LICENSE data
- name: Build (darwin_amd64)
run: |
GOOS=darwin GOARCH=amd64 go build -v -ldflags "-X 'main.buildGoVersion=$(go version)' -X 'main.buildGitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(git show -s --format=%cI)' -X 'main.buildVersion=$(basename ${GITHUB_REF})'" .
- name: Pack (darwin_amd64)
run: |
zip -r deer-executor-darwin-amd64.zip deer-executor lib CHANGELOG COMMANDS.md README.md LICENSE data
- 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 ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./deer-executor-linux-amd64.zip
asset_name: deer-executor-${{ steps.get_version.outputs.TAG }}-linux-amd64.zip
asset_content_type: application/zip
- name: Upload Release Asset (Drawin)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./deer-executor-darwin-amd64.zip
asset_name: deer-executor-${{ steps.get_version.outputs.TAG }}-darwin-amd64.zip
asset_content_type: application/zip
# - name: Test
# run: go test -v .