-
Notifications
You must be signed in to change notification settings - Fork 86
108 lines (81 loc) · 2.86 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
name: Release
on:
# release daily
# https://crontab-generator.org/
schedule:
- cron: '0 8 * * *'
# or on manual trigger
workflow_dispatch:
env:
npmVersion: 8
jobs:
build:
runs-on: ubuntu-latest
# This environment contains secrets needed for publishing
environment: release
steps:
- name: Check out code
uses: actions/checkout@v4
with:
# Don't save creds in the git config (so it's easier to override later)
persist-credentials: false
- name: Install Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
# Guarantee a predictable version of npm (the PR build tests against both 6 and 8)
- name: Install package managers
run: npm install --global npm@${{ env.npmVersion }} yarn@1
- run: yarn --frozen-lockfile
- run: yarn build
- run: yarn test:unit
- run: yarn test:func
- name: yarn test:e2e (npm ${{ env.npmVersion }})
run: yarn test:e2e
- name: Publish package
run: |
git config user.email "[email protected]"
git config user.name "Ken Chau"
# Get the existing remote URL without creds, and use a trap (like try/finally)
# to restore it after this step finishes
trap "git remote set-url origin '$(git remote get-url origin)'" EXIT
# Add a token to the remote URL for auth during release
git remote set-url origin "https://[email protected]/$GITHUB_REPOSITORY"
yarn release -y -n "$NPM_AUTHTOKEN"
env:
NPM_AUTHTOKEN: ${{ secrets.NPM_AUTHTOKEN }}
REPO_PAT: ${{ secrets.REPO_PAT }}
# The docs have a separate installation using Node 20 due to needing newer dependencies
docs:
name: Update docs
needs: build
runs-on: ubuntu-latest
permissions:
# Needed by gh-pages publish
contents: write
steps:
- name: Check out code
uses: actions/checkout@v4
with:
# Don't save creds in the git config (so it's easier to override later)
persist-credentials: false
- name: Install Node.js 20
uses: actions/setup-node@v4
with:
cache: yarn
node-version: 20
- run: yarn --immutable
working-directory: ./docs
- run: yarn docs:build
working-directory: ./docs
- name: Update docs
run: |
git config user.email "[email protected]"
git config user.name "Ken Chau"
# See previous step for explanation
trap "git remote set-url origin '$(git remote get-url origin)'" EXIT
git remote set-url origin "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git"
yarn release:docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./docs