-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (86 loc) · 2.73 KB
/
ci.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
name: CI
on:
push:
# FIXME:
# branches: [main]
# branches: [feature/sc-420243/ci-configuration]
tags: [v*]
# pull_request:
# FIMXE:
# branches: [main]
jobs:
build:
name: Build [Node.js ${{ matrix.node-version }}]
runs-on: ubuntu-22.04
strategy:
matrix:
# FIXME:
# node-version: [18.x, 20.x, 22.x]
node-version: [18.x]
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v4
###
# Build
###
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Enable Corepack
run: corepack enable
- name: Install
run: yarn install
- name: Build
run: yarn build
# FIXME:
# - name: Lint
# run: yarn lint
# - name: Test
# run: yarn test
###
# Release
###
- name: Check tag format
id: check-tag-format
if: startsWith(github.ref, 'refs/tags/')
uses: nowsprinting/check-version-format-action@v4
with:
prefix: 'v'
- name: Exit on invalid tag format
if: startsWith(github.ref, 'refs/tags/') && steps.check-tag-format.outputs.is_valid == 'false'
run: echo "Tag must follow SemVer convention. Aborting." && exit 1
- name: Get release type
if: startsWith(github.ref, 'refs/tags/')
id: get-release-type
uses: actions/github-script@v7
with:
script: |
const regex = /(alpha|beta)/
const refName = context.ref.replace('refs/tags/', '')
console.log(`Ref tag: ${refName}`)
const releaseTypeMatch = refName.match(regex)
if (!releaseTypeMatch) {
releaseType = 'latest'
} else {
releaseType = releaseTypeMatch[0]
}
console.log(`Release type: ${releaseType}`)
return releaseType
# This additional step is needed to configure the yarn auth token
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-using-yarn
- name: Configure yarn to publish
if: startsWith(github.ref, 'refs/tags/')
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cat ~/.npmrc
yarn config set npmPublishRegistry "https://npm.pkg.github.com"
yarn config set npmAuthToken "${NODE_AUTH_TOKEN}"
- name: Publish release
if: startsWith(github.ref, 'refs/tags/')
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn npm publish --tag ${{steps.get-release-type.outputs.result}}