-
Notifications
You must be signed in to change notification settings - Fork 11
120 lines (108 loc) · 4.13 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
name: Upload build asset
on:
release:
types: [published]
jobs:
build:
name: Upload build asset for ${{ matrix.name }}
runs-on: ${{ matrix.os }}
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: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ~1.22
id: go
- name: Checkout code
uses: actions/checkout@v2
- 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 replace-in-files-cli
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}}