-
Notifications
You must be signed in to change notification settings - Fork 111
119 lines (101 loc) · 3.67 KB
/
release.yaml
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
name: Build Release Binaries
on:
release:
types: [created]
workflow_dispatch: {}
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: linux_amd64
artifact: ibazel_linux_amd64
os: ubuntu-18.04
bin: linux_amd64_pure_stripped
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64
ext: ""
- name: windows_amd64
artifact: ibazel_windows_amd64.exe
os: ubuntu-18.04
bin: windows_amd64_pure_stripped
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64
ext: ".exe"
- name: darwin_amd64
artifact: ibazel_darwin_amd64
os: macos-latest
bin: darwin_amd64_stripped
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64_cgo
ext: ""
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Bazelisk
run: npm --global install @bazel/bazelisk@latest
- name: Build ibazel
run: bazel build //ibazel:ibazel --config release ${{ matrix.build_flags }}
- name: Copy binary
run: cp $(bazel info bazel-bin)/ibazel/${{ matrix.bin }}/ibazel${{ matrix.ext }} ${{ matrix.artifact }}
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.name }}
path: ${{ matrix.artifact }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
if: ${{ github.event.release.upload_url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# this hook param can means we can only use this flow when triggered by a release, not manually
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ matrix.artifact }}
asset_name: ${{ matrix.artifact }}
asset_content_type: application/octet-stream
release_npm:
runs-on: ubuntu-18.04
needs: [build]
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: ./npm-staging/bin
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Bazelisk
run: npm --global install @bazel/bazelisk@latest
- name: Prepare ibazel binaries
working-directory: ./npm-staging/bin
run: |
mv darwin_amd64/ibazel_darwin_amd64 darwin_amd64/ibazel
mv linux_amd64/ibazel_linux_amd64 linux_amd64/ibazel
mv windows_amd64/ibazel_windows_amd64.exe windows_amd64/ibazel.exe
chmod 755 */ibazel*
- name: Create NPM Package
run: |
pwd
find .
cp "README.md" "npm-staging/README.md"
cp "release/npm/index.js" "npm-staging/index.js"
cp ".npmrc" "npm-staging/.npmrc"
bazel run --config=release "//release/npm" -- "${PWD}/CONTRIBUTORS" > "npm-staging/package.json"
- name: Upload npm package
uses: actions/upload-artifact@v2
with:
name: npm-package
path: npm-staging/
- name: Publish NPM Package
if: ${{ github.event.release.upload_url }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./npm-staging
run: |
echo -n "Publishing to NPM as "
grep "version" < "package.json"
find . && cat package.json && echo "Publishing to npm..." && npm publish