-
-
Notifications
You must be signed in to change notification settings - Fork 48
109 lines (90 loc) · 3.02 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
101
102
103
104
105
106
107
108
109
name: release
on:
push:
branches:
- master
jobs:
dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.1
# run checks
- run: npm audit --audit-level=moderate
test:
needs: dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.1
with:
node-version: 14
- uses: actions/cache@v2
with:
path: ~/.npm
key: client-${{ hashFiles('**/package-lock.json') }}
# run test
- run: npm ci
- run: npm run test:100
release:
needs: test
runs-on: ubuntu-latest
outputs:
published: ${{ steps.release.outputs.published }}
release-version: ${{ steps.release.outputs.release-version }}
release-version-major: ${{ steps.release.outputs.release-version-major }}
release-version-minor: ${{ steps.release.outputs.release-version-minor }}
steps:
- uses: actions/checkout@v2
- id: release
name: semantic-release
uses: ahmadnassri/action-semantic-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
alias:
needs: release
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
alias:
- version: v${{ needs.release.outputs.release-version-major }}
- version: v${{ needs.release.outputs.release-version-major }}.${{ needs.release.outputs.release-version-minor }}
steps:
- uses: actions/github-script@v2
with:
script: |
const tag = 'tags/${{ matrix.alias.version }}'
const repo = {
owner: context.repo.owner,
repo: context.repo.repo
}
await github.git.deleteRef({ ...repo, ref: tag }).catch(() => {})
await github.git.createRef({ ...repo, ref: `refs/${tag}` , sha: process.env.GITHUB_SHA })
publish:
needs: release
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
docker:
- name: docker hub
registry: registry.hub.docker.com
password: DOCKER_PASSWORD
repository: ${{ github.event.repository.full_name }}
- name: github package registry
password: GITHUB_TOKEN
registry: docker.pkg.github.com
repository: ${{ github.event.repository.full_name }}/${{ github.event.repository.name }}
steps:
- name: checkout
uses: actions/checkout@v2
- name: ${{ matrix.docker.name }}
uses: docker/build-push-action@v1
with:
add_git_labels: true
username: ${{ github.repository_owner }}
password: ${{ secrets[matrix.docker.password] }}
registry: ${{ matrix.docker.registry }}
repository: ${{ matrix.docker.repository }}
tags: latest, v${{ needs.release.outputs.release-version-major }}, ${{ needs.release.outputs.release-version }}