-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (85 loc) · 2.76 KB
/
feature-branch-prerelease.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
name: Prerelease feature branch
on:
workflow_dispatch:
inputs:
releaseType:
type: choice
description: Select dry-run for testing before real prerelease
required: true
options:
- dry-run
- prerelease
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
strategy:
matrix:
node-version: [18.15.x]
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-name@v7
- name: Check out git repository
uses: actions/checkout@v3
with:
ref: ${{ steps.branch-name.outputs.ref_branch }}
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: 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_TOKEN }}" > ~/.npmrc
npm whoami
# Converted to all lowercase and stripped of non-letter characters
- name: Transform feature branch name
run: |
echo "PREID=$(echo '${{ steps.branch-name.outputs.current_branch }}' | tr -cd '[:lower:]')" >> $GITHUB_ENV
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version-file: './package.json,./package-lock.json'
pre-release: 'true'
pre-release-identifier: ${{ env.PREID }}
# Use 'from git' option if `lerna version` has already been run
- name: Publish Release to NPM
if: ${{ github.event.inputs.releaseType == 'prerelease' }}
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}