-
Notifications
You must be signed in to change notification settings - Fork 124
130 lines (112 loc) · 4.56 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
120
121
122
123
124
125
126
127
128
129
130
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-latest
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64
cpu_flag:
ext: ""
- name: linux_arm64
artifact: ibazel_linux_arm64
os: ubuntu-latest
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64
cpu_flag:
ext: ""
- name: windows_amd64
artifact: ibazel_windows_amd64.exe
os: ubuntu-latest
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64
cpu_flag:
ext: ".exe"
- name: darwin_amd64
artifact: ibazel_darwin_amd64
os: macos-latest
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64_cgo
cpu_flag:
ext: ""
- name: darwin_arm64
artifact: ibazel_darwin_arm64
os: macos-latest
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:darwin_arm64_cgo
# TODO: temporary workaround, remove this in the future.
# Right now, without the flag, GitHub actions build would link to the "darwin_amd64" go_sdk toolchain and fail the build.
# related issue: https://github.com/fsnotify/fsevents/issues/50
# also general info on Bazel platforms: https://bazel.build/concepts/platforms#migration
cpu_flag: --cpu=darwin_arm64
ext: ""
steps:
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- name: Build ibazel
run: bazel build //cmd/ibazel:ibazel --config release ${{ matrix.build_flags }} ${{ matrix.cpu_flag }}
- name: Copy binary
run: cp $(bazel info ${{ matrix.cpu_flag }} bazel-bin)/cmd/ibazel/ibazel_/ibazel${{ matrix.ext }} ${{ matrix.artifact }}
- name: Upload binary
uses: actions/upload-artifact@v3
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-latest
needs: [build]
steps:
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
path: ./npm-staging/bin
- name: Prepare ibazel binaries
working-directory: ./npm-staging/bin
run: |
mv darwin_amd64/ibazel_darwin_amd64 darwin_amd64/ibazel
mv darwin_arm64/ibazel_darwin_arm64 darwin_arm64/ibazel
mv linux_amd64/ibazel_linux_amd64 linux_amd64/ibazel
mv linux_arm64/ibazel_linux_arm64 linux_arm64/ibazel
mv windows_amd64/ibazel_windows_amd64.exe windows_amd64/ibazel.exe
chmod 755 */ibazel*
- name: Create NPM Package
run: |
cp "README.md" "npm-staging/README.md"
cp "release/npm/index.js" "npm-staging/index.js"
bazel run --config="release" "//release/npm" -- "${PWD}/CONTRIBUTORS" > "npm-staging/package.json"
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Publish NPM Package
if: ${{ github.event.release.upload_url }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./npm-staging
# The setup-node@v3 step created an .npmrc file, but we changed directories. Copy it first.
run: |
npm config list
echo -n "Publishing to NPM as "
grep "version" < "package.json"
find . && cat package.json && npm install && echo "Publishing to npm..." && npm publish