-
Notifications
You must be signed in to change notification settings - Fork 40
116 lines (99 loc) · 3.46 KB
/
publish-v2.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
109
110
111
112
113
114
115
116
name: Publish v2.x
on:
workflow_dispatch:
inputs:
releaseType:
type: choice
description: Release Type
options:
- release
- prerelease
- graduate
jobs:
authorize:
name: Authorize
runs-on: ubuntu-latest
steps:
- name: ${{ github.actor }} permission check to do a release
uses: 'lannonbr/[email protected]'
with:
permission: 'write'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [authorize]
permissions:
id-token: write
contents: write
env:
RELEASE_TYPE: ${{ github.event.inputs.releaseType }}
strategy:
matrix:
node-version: [18.15.x]
steps:
- name: Check out git repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache dependencies
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install project dependencies
run: |
yarn install --frozen-lockfile
- name: Build all packages
run: |
yarn build
- name: Test all packages
run: |
yarn test
- name: Lint all packages
run: |
yarn lint
- name: Configure Git User
run: |
git config --global user.name amplitude-sdk-bot
git config --global user.email [email protected]
- name: Configure NPM User
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISH_TOKEN }}" > ~/.npmrc
npm whoami
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::358203115967:role/github-actions-role
aws-region: us-west-2
# https://www.npmjs.com/package/@lerna/version#--conventional-prerelease
# patch: 1.0.0 -> 1.0.1-alpha.0
# minor: 1.0.0 -> 1.1.0-alpha.0
# major: 1.0.0 -> 2.0.0-alpha.0
- name: Create pre-release version
if: ${{ env.RELEASE_TYPE == 'prerelease'}}
run: |
GH_TOKEN=${{ secrets.GH_PUBLISH_TOKEN }} npm run deploy:version -- -y --no-private --conventional-prerelease --create-release github
# https://www.npmjs.com/package/@lerna/version#--conventional-graduate
# 1.0.0-alpha.0 -> 1.0.1
- name: Create graduate version
if: ${{ env.RELEASE_TYPE == 'graduate'}}
run: |
GH_TOKEN=${{ secrets.GH_PUBLISH_TOKEN }} npm run deploy:version -- -y --no-private --conventional-graduate --create-release github
# Use 'release' for the usual deployment
# NOTE: You probably want this
- name: Create release version
if: ${{ env.RELEASE_TYPE == 'release'}}
run: |
GH_TOKEN=${{ secrets.GH_PUBLISH_TOKEN }} npm run deploy:version -- -y --no-private --create-release github
# Use 'from git' option if `lerna version` has already been run
- name: Publish Release to NPM
run: |
GH_TOKEN=${{ secrets.GH_PUBLISH_TOKEN }} npm run deploy:publish -- from-git -y --pre-dist-tag beta
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}