-
Notifications
You must be signed in to change notification settings - Fork 78
118 lines (98 loc) · 3.43 KB
/
npm-publish.yml
File metadata and controls
118 lines (98 loc) · 3.43 KB
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
117
118
name: NPM publish
on:
schedule:
- cron: '01 00 * * *' # Every day at 00:01 UTC
workflow_dispatch:
inputs:
latest-build:
description: 'Whether to publish as a latest build'
required: true
type: boolean
permissions:
id-token: write
contents: read
concurrency:
group: 'npm-executorch-package-build'
cancel-in-progress: false
jobs:
build:
if: github.repository == 'software-mansion/react-native-executorch'
runs-on: ubuntu-latest
environment: deployment
permissions:
contents: read
id-token: write
env:
EXECUTORCH_DIR: packages/react-native-executorch
EXECUTORCH_VERSION: PLACEHOLDER
PACKAGE_NAME: PLACEHOLDER
TAG: PLACEHOLDER
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'
registry-url: https://registry.npmjs.org/
- name: Update NPM
run: npm install -g npm@latest
- name: Determine version
working-directory: ${{ env.EXECUTORCH_DIR }}
run: |
VERSION=$(jq -r .version package.json)
echo "EXECUTORCH_VERSION=$VERSION" >> $GITHUB_ENV
- name: Assert EXECUTORCH_VERSION
if: ${{ env.EXECUTORCH_VERSION == 'PLACEHOLDER' }}
run: exit 1 # this should never happen
- name: Install monorepo dependencies
run: yarn install --immutable
- name: Set tag
run: |
if [[ "${{ inputs.latest-build }}" != "true" ]]; then
echo "TAG=executorch-nightly" >> $GITHUB_ENV
else
echo "TAG=latest" >> $GITHUB_ENV
fi
- name: Assert tag
if: ${{ env.TAG == 'PLACEHOLDER' }}
run: exit 1 # this should never happen
- name: Build package
id: build
working-directory: ${{ env.EXECUTORCH_DIR }}
run: |
if [[ "${{ inputs.latest-build }}" != "true" ]]; then
./scripts/create-package.sh generate_nightly_version
else
./scripts/create-package.sh
fi
- name: Check if any node_modules were packed
id: check_node_modules
working-directory: ${{ env.EXECUTORCH_DIR }}
run: >-
! grep --silent -E "node_modules/.+" build.log
- name: Show build log
working-directory: ${{ env.EXECUTORCH_DIR }}
if: failure() && steps.build.outcome == 'failure'
run: cat build.log
- name: Show packed node_modules
working-directory: ${{ env.EXECUTORCH_DIR }}
if: failure() && steps.node_modules.outcome == 'failure'
run: >-
! grep -E "node_modules/.+" build.log
- name: Add package name to env
working-directory: ${{ env.EXECUTORCH_DIR }}
run: echo "PACKAGE_NAME=$(ls -l | egrep -o "react-native-executorch-(.*)(=?\.tgz)")" >> $GITHUB_ENV
- name: Assert package name
if: ${{ env.PACKAGE_NAME == 'PLACEHOLDER' }}
run: exit 1 # this should never happen
- name: Upload package to GitHub
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}
path: ${{ env.EXECUTORCH_DIR }}/${{ env.PACKAGE_NAME }}
- name: Move package to monorepo root
run: mv ${{ env.EXECUTORCH_DIR }}/${{ env.PACKAGE_NAME }} .
- name: Publish package to npm
run: npm publish $PACKAGE_NAME --tag ${{ env.TAG }} --provenance