-
Notifications
You must be signed in to change notification settings - Fork 17
142 lines (134 loc) · 4.98 KB
/
nodejs.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
name: casanet server CI CD
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update version patch
if: github.ref == 'refs/heads/master'
id: update_version
run: |
cd backend
version=$(npm --no-git-tag-version --tag-version-prefix= version patch)
cd ..
echo $version > version.txt
echo $version
echo "VERSION=$version" >> $GITHUB_OUTPUT
- name: Commit and push changes
if: github.ref == 'refs/heads/master'
uses: devops-infra/action-commit-push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: Update to version ${{ steps.update_version.outputs.VERSION }} [skip-ci]
- name: Bundle packages
# NOTE, the default ARMV bin (v16.12.0) not exists in the "https://github.com/vercel/pkg-fetch/releases" page, so download V16.8 and replace name and hash to build using it
run: |
export BRANCH=${GITHUB_REF##*/}
mkdir casanet_bin
mkdir .pkg-cache
cd .pkg-cache
export PKG_CACHE_PATH=$(pwd)
echo $PKG_CACHE_PATH
mkdir v3.4
cd v3.4
curl -L https://github.com/vercel/pkg-fetch/releases/download/v3.4/node-v16.16.0-linuxstatic-armv7 --output fetched-v16.16.0-linux-armv7
chmod 777 fetched-v16.16.0-linux-armv7
cd ../../
cd backend
npm i -g yarn
yarn --frozen-lockfile
sed -i 's/node-v16.16.0-linuxstatic-armv7/node-v16.16.0-linux-armv7/g' node_modules/pkg-fetch/lib-es5/expected.js
sed -i 's/e26b713c159d38b09ba8db95e4c8220653386aad7bc6ec0921f6b6b20f4710c5/cbe14ff111fd3d1ecb82cf6aaec5a53588537008fdcfab4bc2c880d651f5580a/g' node_modules/pkg-fetch/lib-es5/expected.js
npm run bundle
cp dist/generated/swagger.json ../casanet_bin/swagger.json
cp -v bundle/* ../casanet_bin
- uses: actions/upload-artifact@v3
with:
name: casanet_bin
path: casanet_bin
- uses: actions/upload-artifact@v3
with:
name: swagger-spec
path: backend/dist/generated/swagger.json
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
if: github.ref != 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: test backend
run: |
cd backend
npm i -g yarn
yarn --frozen-lockfile
npm run test
release:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@master
with:
name: casanet_bin
path: casanet_bin
- name: Get the version
id: get_version
run: |
cd backend
version=$(npm --no-git-tag-version --tag-version-prefix= version patch)
cd ..
echo $version > version.txt
echo "VERSION=$version" >> $GITHUB_OUTPUT
title=$(git log -1 --pretty=%B | sed -n '1p')
echo "TITLE=$title" >> $GITHUB_OUTPUT
body=$(git log -1 --pretty=%B | sed 1d)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "BODY=$body" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
name: ${{ steps.get_version.outputs.TITLE }}
body: ${{ steps.get_version.outputs.BODY }}
draft: false
prerelease: true
files: |
./casanet_bin/casanet_linux_arm
./casanet_bin/casanet_win_x64.exe
./casanet_bin/casanet_linux_x64
./casanet_bin/casanet.json
./casanet_bin/swagger.json
- name: Upload Spec To Hub # And finally all ready to upload new spec version to swagger hub
env:
SWAGGERHUB_API_KEY: '${{ secrets.SWAGGERHUB_API_KEY }}' # Export the SWAGGERHUB_API_KEY secret as environment variable, use to auth publish request
API_SERVER_URL: '${{ secrets.API_SERVER_URL }}' # Export the API_SERVER_URL secret as environment variable, used to set the API Server URL to the published spec.
run: | # Update the spec with the API Server URL
node ./backend/scripts/set-spec-server.js ./casanet_bin/swagger.json $API_SERVER_URL
npx swaggerhub-cli api:create haimkastner/casanet-local-server --file ./casanet_bin/swagger.json --published=publish --visibility=public --setdefault