-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (86 loc) · 2.95 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
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
CKEDITOR_LICENSE_KEY_PRODUCTION: ${{ secrets.CKEDITOR_LICENSE_KEY_PRODUCTION}}
CKEDITOR_LICENSE_KEY_DEVELOPMENT: ${{ secrets.CKEDITOR_LICENSE_KEY_DEVELOPMENT}}
NODE_VERSION: "20"
jobs:
release: # action to create changesets
name: Create Changeset PR
runs-on: ubuntu-latest
outputs:
changeset: ${{ steps.changesets.outputs.hasChangesets }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm-publish:
name: Build + Publish
runs-on: ubuntu-latest
needs: release
if: ${{ needs.release.outputs.changeset == 'false' }}
environment: npm-publish
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
# Use yarn2
- name: Install Yarn
run: npm install -g yarn
- name: Set Yarn Version
run: yarn set version berry
- id: find-yarn-cache-folder
name: Find Yarn's cache folder
run: echo "YARN_CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_ENV
- name: Cache Yarn's cache folder
uses: actions/cache@v3
with:
path: ${{ env.YARN_CACHE_FOLDER }}
key: yarn-cache-folder-os-${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-cache-folder-os-${{ runner.os }}-node-${{ env.NODE_VERSION }}-
yarn-cache-folder-os-${{ runner.os }}-
- name: Install oauth
run: |
sudo apt-get install --fix-broken --yes oathtool
- name: Setup yarn
run: |
yarn config set npmPublishAccess public
yarn config set npmAlwaysAuth true
yarn config set npmRegistryServer https://registry.npmjs.org
yarn config set npmAuthToken $NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Git config user
run: |
git config user.name zendesk-ops-ci
git config user.email [email protected]
- name: Build and release
run: |
yarn install --immutable
yarn build
totp=$(oathtool --base32 --totp "${NPM_TOTP_DEVICE}")
yarn npm publish --otp $totp
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOTP_DEVICE: ${{ secrets.NPM_TOTP_DEVICE }}
- name: Clear the .yarnrc.yml file
if: always()
run: rm -f .yarnrc.yml