-
-
Notifications
You must be signed in to change notification settings - Fork 10
70 lines (62 loc) · 2.34 KB
/
build_test_publish.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
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build_test_publish:
name: Build, test and publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set environment variables
run: |
GH_COMMIT_MESSAGE="$(head -n 1 <<< "${{github.event.head_commit.message}}")"
GIT_COMMIT_MESSAGE="$(git log --format=%B -n 1 ${{github.event.after}} | head -n 1)"
echo "COMMIT_MESSAGE=\"$(test "${GH_COMMIT_MESSAGE}" && echo "${GH_COMMIT_MESSAGE}" || echo "${GIT_COMMIT_MESSAGE}")\"" >> $GITHUB_ENV
echo "PR_TITLE=\"${{github.event.pull_request.title}}\"" >> $GITHUB_ENV
cat "${GITHUB_ENV}"
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Set yarn cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Get yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
restore-keys: ${{runner.os}}-yarn-
- name: Build, lint and test
run: |
yarn
yarn boot
yarn lint
yarn dist
yarn test
- name: Release
if: |
github.event_name != 'pull_request' &&
!startsWith(env.COMMIT_MESSAGE || env.PR_TITLE, '"chore')
env:
GIT_AUTHOR_NAME: ffflobot
GIT_AUTHOR_EMAIL: ffflobot@users.noreply.github.com
GIT_COMMITTER_NAME: ffflobot
GIT_COMMITTER_EMAIL: ffflobot@users.noreply.github.com
GH_USER: ffflobot
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
run: |
git config --global "user.email" "${GIT_AUTHOR_EMAIL}"
git config --global "user.name" "${GIT_AUTHOR_NAME}"
REPO_URL="$(git remote get-url origin | sed -n "s/https:\/\/github.com\//https:\/\/${GIT_AUTHOR_NAME}:${GITHUB_TOKEN}@github.com\//p")"
git remote set-url origin "${REPO_URL}"
git checkout main
./bin/rebuild-docs.sh
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> "${HOME}/.npmrc"
yarn release