forked from software-mansion/react-native-reanimated
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (88 loc) · 2.76 KB
/
build-npm-package-action.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
name: Build npm package
on:
workflow_call:
inputs:
version:
required: true
type: string
ref:
required: false
type: string
upload_binaries:
required: false
type: boolean
publish_on_npm:
required: false
type: boolean
secrets:
NODE_AUTH_TOKEN:
required: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/
- name: Clear annotations
run: scripts/clear-annotations.sh
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Install NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21d
- name: Build package
env:
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
run: >-
./createNPMPackage.sh ${{ inputs.version }} 2> build.log
- name: Check if any node_modules were packed
id: node_modules
run: >-
! grep --silent -E "node_modules/.+"
- name: Check if size is over 1MB
if: ${{ inputs.ref != 'Reanimated2' }}
id: size
run: grep --silent -E "npm notice package size:\s*[0-9][0-9]?[0-9]?(\.[0-9]*)?\s*kB" build.log
- name: Show build log
if: failure() && steps.build.outcome == 'failure'
run: >-
cat build.log
- name: Show packed node_modules
if: failure() && steps.node_modules.outcome == 'failure'
run: >-
! grep -E "node_modules/.+"
- name: Show exceeded package size
if: failure() && steps.size.outcome == 'failure'
run: grep -E "npm notice package size:" build.log
- run: echo "PACKAGE_NAME=$(ls -l | egrep -o "react-native-reanimated-(.*)(=?\.tgz)")" >> $GITHUB_ENV
- name: Upload npm package
uses: actions/upload-artifact@v3
with:
name: ${{ env.PACKAGE_NAME }}
path: '*.tgz'
- name: Compress Android build output
if: ${{ inputs.upload_binaries }}
run: zip -r android-build-output.zip build_output
- name: Upload Android build folder
if: ${{ inputs.upload_binaries }}
uses: actions/upload-artifact@v3
with:
name: android-build-output
path: android-build-output.zip
retention-days: 5
- run: npm publish $PACKAGE_NAME --tag nightly
if: ${{ inputs.publish_on_npm }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}