-
Notifications
You must be signed in to change notification settings - Fork 6
84 lines (72 loc) · 2.44 KB
/
build.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
name: build
on:
push:
branches:
- master
- /^\d+\.\d+\.\d(-alpha\.\d+|-beta\.\d+|-rc\.\d+)?$/
tags:
- "*"
pull_request:
branches:
- master
jobs:
build:
name: Test, Build & Release
runs-on: "ubuntu-latest"
env:
LOGS_DIR: /tmp/code-style/logs
LOGS_FILE: /tmp/code-style/logs/build-perf.log
NPM_VERSION: "10.x"
TZ: "Europe/Brussels"
steps:
# See: https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v4
# See: https://github.com/marketplace/actions/setup-node-js-environment
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Create file & folder for GitHub Actions logs
run: |
# cfr scripts/_ghactions-group.sh
mkdir -p $LOGS_DIR
touch $LOGS_FILE
- name: Get tag name if exists
run: |
TAG_NAME=$(echo $GITHUB_REF | sed -n "s/^refs\/tags\/\(\S*\).*$/\1/p")
echo "GH_ACTIONS_TAG=${TAG_NAME}" >> $GITHUB_ENV
- name: List main variables
run: |
echo "Commit SHA : ${GITHUB_SHA}"
echo "Tag name : ${GH_ACTIONS_TAG}"
echo "Reference : ${GITHUB_REF}"
echo "Head branch : ${GITHUB_HEAD_REF}"
echo "Base branch : ${GITHUB_BASE_REF}"
echo "Build number: ${GITHUB_RUN_NUMBER}"
echo "Repository : ${GITHUB_REPOSITORY}"
echo "Event : ${GITHUB_EVENT_NAME}"
echo "Author : ${GITHUB_ACTOR}"
NODE_VERSION="$(node -v)"
echo "Node version: $NODE_VERSION"
npm i -g npm@${NPM_VERSION}
# This ensures that we are authenticated without requiring to have an actual .npmrc file within the project
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
env:
GH_ACTIONS_TAG: ${{ steps.get_tag_name.outputs.TAG_NAME }}
- name: Install dependencies
run: npm ci
- name: Test
run: npm test
- name: Build
run: npm run build
# See: https://github.com/marketplace/actions/upload-a-build-artifact
- uses: actions/upload-artifact@v3
with:
name: dist-${{ github.run_id }}
path: dist
- name: Release
run: npm run release:publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Save logs
run: bash ./scripts/ci/print-logs.sh