-
Notifications
You must be signed in to change notification settings - Fork 11
141 lines (125 loc) · 4.66 KB
/
tag.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Tag
on:
release:
types: [published]
jobs:
build:
name: Build & upload ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
CGO_ENABLED: '0'
strategy:
matrix:
include:
- name: linux amd64
os: ubuntu-latest
buildCmd: env GOOS=linux GOARCH=amd64 go build -o builds/zcli-linux-amd64 -ldflags "-s -w -X github.com/zeropsio/zcli/src/cmd.version=${{ github.event.release.tag_name }}" ./cmd/zcli/main.go
file: zcli-linux-amd64
compress: true
strip: true
runLint: true
runTests: true
- name: linux 386
os: ubuntu-latest
buildCmd: env GOOS=linux GOARCH=386 go build -o builds/zcli-linux-i386 -ldflags "-s -w -X github.com/zeropsio/zcli/src/cmd.version=${{ github.event.release.tag_name }}" ./cmd/zcli/main.go
file: zcli-linux-i386
compress: true
strip: true
runLint: true
runTests: true
- name: darwin amd64
os: macos-latest
buildCmd: env GOOS=darwin GOARCH=amd64 go build -o builds/zcli-darwin-amd64 -ldflags "-s -w -X github.com/zeropsio/zcli/src/cmd.version=${{ github.event.release.tag_name }}" ./cmd/zcli/main.go
file: zcli-darwin-amd64
compress: false
strip: false
runLint: true
runTests: true
- name: darwin arm64
os: macos-latest
buildCmd: env GOOS=darwin GOARCH=arm64 go build -o builds/zcli-darwin-arm64 -ldflags "-s -w -X github.com/zeropsio/zcli/src/cmd.version=${{ github.event.release.tag_name }}" ./cmd/zcli/main.go
file: zcli-darwin-arm64
compress: false
strip: false
runLint: false
runTests: false
- name: windows amd64
os: ubuntu-latest
buildCmd: env GOOS=windows GOARCH=amd64 go build -o builds/zcli-win-x64.exe -ldflags "-s -w -X github.com/zeropsio/zcli/src/cmd.version=${{ github.event.release.tag_name }}" ./cmd/zcli/main.go
file: zcli-win-x64.exe
compress: false
strip: false
runLint: false
runTests: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
id: go
- name: Get dependencies
run: |
export GOPATH=$HOME/go
./tools/install.sh
- name: Build
run: ${{ matrix.buildCmd }}
- name: Compress binary
if: ${{ matrix.compress }}
uses: svenstaro/upx-action@v2
with:
file: ./builds/${{ matrix.file }}
strip: ${{ matrix.strip }}
- name: Package binaries for NPM
run: tar -czvf ${{ matrix.file }}-npm.tar.gz builds/${{ matrix.file }}
- name: Upload asset for NPM
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ matrix.file }}-npm.tar.gz
asset_name: ${{ matrix.file }}-npm.tar.gz
asset_content_type: application/octet-stream
- name: Upload asset clean bin
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./builds/${{ matrix.file }}
asset_name: ${{ matrix.file }}
asset_content_type: application/octet-stream
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: |
cd tools/npm
npm ci --ignore-scripts
npm i -g [email protected]
replace-in-files --string='v0.0.0-zerops' --replacement='${{ github.event.release.tag_name }}' package.json
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
report:
needs: build
runs-on: ubuntu-latest
steps:
- name: Notify discord about new release
uses: sarisia/[email protected]
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "New version of `zcli` is ready!"
nocontext: 'true'
description: |
Version `${{ github.event.release.tag_name }}`
Changelog [here](${{ github.event.release.html_url }})
color: 0xff91a4
username: GitHub