-
Notifications
You must be signed in to change notification settings - Fork 11
204 lines (171 loc) · 5.96 KB
/
deploy.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: Automated deploy
on:
release:
types: [ created ]
env:
VERSION: ${{ github.event.release.tag_name }}
TARGET_REF: ${{ github.event.release.target_commitish }}
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}
- name: Install deps
uses: ./.github/workflows/composite/npm
build:
runs-on: ubuntu-latest
needs: install-deps
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}
- name: Install deps
uses: ./.github/workflows/composite/npm
- name: Set default distribution
run: npm pkg set brightCli.distribution=package
- name: Build package
run: npm run build
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
- name: Pack artifacts
run: npm pack
- uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./brightsec-cli-*
tag: ${{ github.ref }}
file_glob: true
- uses: actions/upload-artifact@v4
with:
name: build
path: |
dist
Dockerfile
package.json
package-lock.json
README.md
LICENSE
tools
generate-binary:
needs: build
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
target: win
node: 20
- os: macos-12
target: macos
node: 20
# Using the `centos7-devtoolset7` runner instead of latest (i.e. `ubuntu-20.04`)
# with gcc 7 but glibc 2.17, so binaries are compatible for Ubuntu 14.04 and Debian 8.
- os: ubuntu-20.04
target: linux
node: 16
container:
image: centos/devtoolset-7-toolchain-centos7:7
options: "--user root"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: build
- name: Install dev-deps
if: startsWith(matrix.os, 'ubuntu')
run: |
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* \
&& sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* \
&& yum install build-essential python3 -y \
&& yum clean all -y \
&& rm -rf /var/cache/yum
- name: Install deps
uses: ./.github/workflows/composite/npm
with:
version: ${{ matrix.node }}
- name: Set distribution
run: npx json -I -f package.json -e "this.brightCli.distribution='${{ matrix.target }}-executable'"
- name: Build executable file
run: npm run build:pkg -- -t node${{ matrix.node }}-${{ matrix.target }}-x64
- name: Build MSI
if: startsWith(matrix.os, 'win')
run: .\tools\scripts\build-msi.ps1
shell: pwsh
- uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ startsWith(matrix.os, 'win') && '.\bin\cli.exe' || './bin/cli' }}
asset_name: ${{ format('bright-cli-{0}-x64{1}', matrix.target, startsWith(matrix.os, 'win') && '.exe' || '') }}
tag: ${{ github.ref }}
- uses: svenstaro/[email protected]
if: startsWith(matrix.os, 'win')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: .\bin\bright-cli.msi
asset_name: bright-cli.msi
tag: ${{ github.ref }}
publish:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: build
- name: Setup node
uses: ./.github/workflows/composite/npm
- name: Set TAG based on target_commitish
run: |
if [ "${{ github.event.release.target_commitish }}" == "next" ]; then
echo "TAG=next" >> $GITHUB_ENV
elif [ "${{ github.event.release.target_commitish }}" == "alpha" ]; then
echo "TAG=alpha" >> $GITHUB_ENV
elif [ "${{ github.event.release.target_commitish }}" == "master" ]; then
echo "TAG=latest" >> $GITHUB_ENV
else
exit 1
fi
- name: Set NPM distribution
run: npm pkg set brightCli.distribution=npm
- run: npm publish --tag $TAG
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# The scope does not align with the package name
# FIXME: once GitHub organization name has been changed, we should prevent this behavior
- name: Prepare GPR package
run: |
npm pkg set name='@neuralegion/bright-cli' \
&& npm pkg set brightCli.distribution=gpr
- name: Setup node
uses: ./.github/workflows/composite/npm
with:
registry: 'https://npm.pkg.github.com'
scope: '@NeuraLegion'
- run: npm publish --tag $TAG
env:
NODE_AUTH_TOKEN: ${{ secrets.GPR_TOKEN }}
- run: sleep 30
- name: Prepare Image Tags
run: |
echo "TAG_REPEATER=brightsec/cli" >> $GITHUB_ENV
- name: Build Images
run: |
docker build . --file Dockerfile --build-arg VERSION=$VERSION -t $TAG_REPEATER:$VERSION -t $TAG_REPEATER:$TAG
- name: Push Images
run: |
docker login --username=${{ secrets.DOCKERHUB_BRIGHT_USER }} --password=${{ secrets.DOCKERHUB_BRIGHT_TOKEN }}
docker push $TAG_REPEATER --all-tags