This repository has been archived by the owner on Nov 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
100 lines (86 loc) · 2.78 KB
/
release.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
name: Release
on:
push:
tags:
- '*'
env:
YARN_CACHE_FOLDER: ~/.yarn
IMAGE_NAME: exoframe/server
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ${{ env.YARN_CACHE_FOLDER }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: https://registry.npmjs.org
- name: install
run: yarn --frozen-lockfile
# lint, test, report coverage
- name: lint
run: yarn lint
- name: test
run: yarn test
# upload coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
publish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ${{ env.YARN_CACHE_FOLDER }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: https://registry.npmjs.org
# build
- name: install
run: yarn --frozen-lockfile
- name: build
run: yarn build
# deploy to npm
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
# build docker image and deploy to hub
- name: Login to DockerHub Registry
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build & push docker image
run: |
REF=${GITHUB_REF##*/}
TAG=$REF
DEBUG_TAG="debug_$TAG"
VERSION=$(node -pe "require('./package.json').version")
echo REF=$GITHUB_REF
echo TAG=$TAG
echo DEBUG_TAG=$DEBUG_TAG
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
# Build docker image
docker build -f docker/Dockerfile --quiet --cache-from $IMAGE_NAME:$TAG --label "version=$VERSION" -t $IMAGE_NAME:$TAG .
# Build debug docker image
docker build -f docker/Dockerfile.debug --quiet --cache-from $IMAGE_NAME:$DEBUG_TAG --label "version=$VERSION" -t $IMAGE_NAME:$DEBUG_TAG .
# if git action = tag
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
docker tag $IMAGE_NAME:$TAG $IMAGE_NAME:latest
docker tag $IMAGE_NAME:$TAG $IMAGE_NAME:debug_latest
else
echo "No tag, skipping"
fi
# Push all images to registry
docker push $IMAGE_NAME