-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathgithub-release-draft-pr-workflow.yml
More file actions
226 lines (199 loc) · 7.35 KB
/
github-release-draft-pr-workflow.yml
File metadata and controls
226 lines (199 loc) · 7.35 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: React Native CI/CD with GitHub Releases
on:
push:
branches: [main, master, develop]
paths-ignore:
- "**.md"
- "LICENSE"
- "docs/**"
pull_request:
branches: [main, master]
workflow_dispatch:
inputs:
buildType:
type: choice
description: "Build type to run"
options:
- all
- dev
- prod-apk
- prod-aab
env:
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
# Keeping legacy provider for older Node.js versions
NODE_OPTIONS: --openssl-legacy-provider
jobs:
test:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: 🏗 Checkout repository
uses: actions/checkout@v4
- name: 🏗 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: 📦 Install dependencies
run: yarn install
- name: 🧪 Run TypeScript check
run: yarn tsc
- name: 🧹 Run ESLint
run: yarn lint
- name: 🎨 Run Prettier check
run: yarn format:check
build-and-release:
needs: test
if: (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')) || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: 🏗 Checkout repository
uses: actions/checkout@v4
- name: 🏗 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: 📦 Install dependencies
run: |
yarn install
yarn global add eas-cli@latest
- name: 🔄 Verify EAS CLI installation
run: |
echo "EAS CLI version:"
eas --version
# Create or update eas.json if needed
if [ ! -f ./eas.json ]; then
echo "Creating default eas.json"
echo '{
"cli": {
"version": ">= 0.50.0"
},
"build": {
"development": {
"distribution": "internal",
"android": {
"gradleCommand": ":app:assembleDebug"
},
"ios": {
"buildConfiguration": "Debug"
}
},
"production-apk": {
"distribution": "internal",
"android": {
"gradleCommand": ":app:assembleRelease"
}
},
"production": {
"distribution": "store",
"android": {
"buildType": "app-bundle"
}
}
}
}' > ./eas.json
fi
- name: 📋 Fix package.json main entry
run: |
# Check if jq is installed, if not install it
if ! command -v jq &> /dev/null; then
echo "Installing jq..."
sudo apt-get update && sudo apt-get install -y jq
fi
# Fix the main entry in package.json
if [ -f ./package.json ]; then
# Create a backup
cp package.json package.json.bak
# Update the package.json
jq '.main = "node_modules/expo/AppEntry.js"' package.json > package.json.tmp && mv package.json.tmp package.json
echo "Updated package.json main entry"
cat package.json | grep "main"
else
echo "package.json not found"
exit 1
fi
- name: 📋 Update metro.config.js
run: |
if [ -f ./metro.config.js ]; then
echo "Creating backup of metro.config.js"
cp ./metro.config.js ./metro.config.js.backup
echo "Updating metro.config.js to CommonJS format"
cat > ./metro.config.js << 'EOFMARKER'
/* eslint-disable @typescript-eslint/no-var-requires */
const { getDefaultConfig } = require('expo/metro-config');
const config = getDefaultConfig(__dirname);
const { transformer, resolver } = config;
config.transformer = {
...transformer,
babelTransformerPath: require.resolve('react-native-svg-transformer/expo'),
};
config.resolver = {
...resolver,
assetExts: resolver.assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...resolver.sourceExts, 'svg'],
};
module.exports = config;
EOFMARKER
echo "metro.config.js updated to CommonJS format"
else
echo "metro.config.js not found"
fi
- name: 📱 Build Development APK
if: github.event.inputs.buildType == 'all' || github.event.inputs.buildType == 'dev' || github.event_name == 'push'
run: |
# Build with increased memory limit
export NODE_OPTIONS="--openssl-legacy-provider --max_old_space_size=4096"
eas build --platform android --profile development --local --non-interactive --output=./app-dev.apk
env:
NODE_ENV: development
- name: 📱 Build Production APK
if: github.event.inputs.buildType == 'all' || github.event.inputs.buildType == 'prod-apk' || github.event_name == 'push'
run: |
export NODE_OPTIONS="--openssl-legacy-provider --max_old_space_size=4096"
eas build --platform android --profile production-apk --local --non-interactive --output=./app-prod.apk
env:
NODE_ENV: production
- name: 📱 Build Production AAB
if: github.event.inputs.buildType == 'all' || github.event.inputs.buildType == 'prod-aab' || github.event_name == 'push'
run: |
export NODE_OPTIONS="--openssl-legacy-provider --max_old_space_size=4096"
eas build --platform android --profile production --local --non-interactive --output=./app-prod.aab
env:
NODE_ENV: production
- name: 📦 Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: app-builds
path: |
./app-dev.apk
./app-prod.apk
./app-prod.aab
retention-days: 7
- name: 🏷️ Generate build information
id: build-info
run: |
VERSION=$(node -p "require('./app.json').expo.version")
BUILD_NUMBER=$(date +%Y%m%d%H%M)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT
# Generate changelog from commit messages since last tag
if git describe --tags --abbrev=0 > /dev/null 2>&1; then
LAST_TAG=$(git describe --tags --abbrev=0)
git log $LAST_TAG..HEAD --pretty=format:"- %s" > changelog.md
else
git log --pretty=format:"- %s" -n 10 > changelog.md
fi
- name: 📝 Create GitHub Release
uses: softprops/action-gh-release@v1
with:
draft: true
name: "Release v${{ steps.build-info.outputs.version }}-${{ steps.build-info.outputs.build_number }}"
tag_name: "v${{ steps.build-info.outputs.version }}-${{ steps.build-info.outputs.build_number }}"
files: |
./app-dev.apk
./app-prod.apk
./app-prod.aab
body_path: changelog.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}