Skip to content

Commit 4de6054

Browse files
committed
optimise ci
1 parent b39d59b commit 4de6054

24 files changed

Lines changed: 195 additions & 139 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI Failure Email
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- ci
7+
- Publish Package to npmjs
8+
types: [completed]
9+
10+
jobs:
11+
notify:
12+
if: contains(fromJSON('["failure","timed_out","action_required"]'), github.event.workflow_run.conclusion)
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Send failure email
16+
uses: dawidd6/action-send-mail@v16
17+
with:
18+
connection_url: ${{ secrets.CI_FAILURE_MAIL_CONNECTION }}
19+
subject: "[CI failed] ${{ github.repository }} / ${{ github.event.workflow_run.name }}"
20+
to: sunnylqm@gmail.com
21+
from: "GitHub Actions <sunnylqm@gmail.com>"
22+
body: |
23+
Repository: ${{ github.repository }}
24+
Workflow: ${{ github.event.workflow_run.name }}
25+
Conclusion: ${{ github.event.workflow_run.conclusion }}
26+
Branch: ${{ github.event.workflow_run.head_branch }}
27+
Commit: ${{ github.event.workflow_run.head_sha }}
28+
Actor: ${{ github.event.workflow_run.actor.login }}
29+
Run: ${{ github.event.workflow_run.html_url }}

.github/workflows/claude.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
id-token: write
2727
steps:
2828
- name: Checkout repository
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@v6
3030
with:
3131
fetch-depth: 1
3232

.github/workflows/lint.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,23 @@ jobs:
1212
runs-on: ubuntu-latest
1313
timeout-minutes: 10
1414
steps:
15-
- uses: actions/checkout@v5
15+
- uses: actions/checkout@v6
16+
with:
17+
fetch-depth: 0
18+
1619
- uses: oven-sh/setup-bun@v2
20+
1721
# Setup .npmrc file to publish to npm
1822
- uses: actions/setup-node@v6
1923
with:
2024
node-version: '24.x'
2125
registry-url: 'https://registry.npmjs.org'
26+
2227
- run: bun install --frozen-lockfile
28+
29+
- name: Prepare publish version
30+
run: bun scripts/prepublish.ts
31+
2332
- name: Publish to npm
2433
shell: bash
2534
run: |

.github/workflows/test.yml

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test
1+
name: ci
22

33
on:
44
pull_request:
@@ -13,37 +13,89 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16-
test:
16+
lint:
1717
runs-on: ubuntu-latest
1818
timeout-minutes: 10
1919

20-
strategy:
21-
matrix:
22-
node-version: [20.x]
20+
steps:
21+
- uses: actions/checkout@v6
22+
23+
- uses: oven-sh/setup-bun@v2
24+
25+
- uses: actions/setup-node@v6
26+
with:
27+
node-version: '24.x'
28+
registry-url: 'https://registry.npmjs.org'
29+
30+
- name: Install Dependency
31+
env:
32+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: bun install --frozen-lockfile
34+
35+
- name: Run lint and typecheck
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: bun run lint
39+
40+
test:
41+
runs-on: ubuntu-latest
42+
timeout-minutes: 10
2343

2444
steps:
25-
- uses: actions/checkout@v4
45+
- uses: actions/checkout@v6
46+
2647
- uses: oven-sh/setup-bun@v2
27-
- uses: actions/setup-node@v4
48+
49+
- uses: actions/setup-node@v6
2850
with:
29-
node-version: ${{ matrix.node-version }}
51+
node-version: '24.x'
3052
registry-url: 'https://registry.npmjs.org'
3153

3254
- name: Install Dependency
3355
env:
3456
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
NODE_OPTIONS: '--max_old_space_size=4096'
3657
run: bun install --frozen-lockfile
3758

3859
- name: Run unit tests with coverage
3960
env:
4061
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
NODE_OPTIONS: '--max_old_space_size=4096'
4262
run: bun run test:coverage
4363

4464
- name: Upload coverage artifact
45-
uses: actions/upload-artifact@v4
65+
uses: actions/upload-artifact@v7
4666
with:
4767
name: coverage
4868
path: coverage
4969
if-no-files-found: error
70+
71+
publish-dry-run:
72+
runs-on: ubuntu-latest
73+
timeout-minutes: 10
74+
75+
steps:
76+
- uses: actions/checkout@v6
77+
with:
78+
fetch-depth: 0
79+
80+
- uses: oven-sh/setup-bun@v2
81+
82+
- uses: actions/setup-node@v6
83+
with:
84+
node-version: '24.x'
85+
registry-url: 'https://registry.npmjs.org'
86+
87+
- name: Install Dependency
88+
env:
89+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
run: bun install --frozen-lockfile
91+
92+
- name: Prepare dry run publish version
93+
env:
94+
PUBLISH_DRY_RUN: 'true'
95+
PUBLISH_VERSION: 0.0.0-dry-run.${{ github.run_id }}.${{ github.run_attempt }}
96+
run: bun scripts/prepublish.ts
97+
98+
- name: Dry run publish
99+
env:
100+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
run: npm publish --dry-run --access public --tag dry-run

package.json

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,33 @@
3030
"default": "./lib/diff.js"
3131
}
3232
},
33-
"files": ["lib", "src", "proto", "cli.json"],
33+
"files": [
34+
"lib",
35+
"src",
36+
"proto",
37+
"cli.json"
38+
],
3439
"scripts": {
35-
"build": "rm -rf lib && swc src -d lib --strip-leading-paths && tsc -p tsconfig.build.json",
36-
"prepublishOnly": "bun scripts/prepublish.ts && bun run build && chmod +x lib/index.js",
37-
"lint": "tsc --noEmit && biome check --write .",
40+
"build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build",
41+
"prepublishOnly": "bun run build && chmod +x lib/index.js",
42+
"typecheck": "tsc --noEmit",
43+
"typecheck:build": "tsc -p tsconfig.build.json",
44+
"lint": "bun run typecheck && biome check .",
45+
"lint:fix": "bun run typecheck && biome check --write .",
3846
"test": "bun test",
3947
"test:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov"
4048
},
4149
"repository": {
4250
"type": "git",
4351
"url": "git+https://github.com/reactnativecn/react-native-update-cli.git"
4452
},
45-
"keywords": ["react-native", "ios", "android", "harmony", "update"],
53+
"keywords": [
54+
"react-native",
55+
"ios",
56+
"android",
57+
"harmony",
58+
"update"
59+
],
4660
"author": "reactnativecn",
4761
"license": "BSD-3-Clause",
4862
"bugs": {
@@ -98,5 +112,8 @@
98112
"@types/yazl": "^2.4.6",
99113
"typescript": "^6.0.2"
100114
},
101-
"trustedDependencies": ["@biomejs/biome", "@swc/core"]
115+
"trustedDependencies": [
116+
"@biomejs/biome",
117+
"@swc/core"
118+
]
102119
}

scripts/prepublish.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,18 @@ async function modifyPackageJson({
3535
}
3636

3737
async function main(): Promise<void> {
38-
const version = (await $`git describe --tags --always`.text())
38+
const isDryRun =
39+
process.env.PUBLISH_DRY_RUN === 'true' ||
40+
process.env.npm_config_dry_run === 'true';
41+
42+
const gitVersion = (await $`git describe --tags --always`.text())
3943
.replace('v', '')
4044
.trim();
45+
const version = process.env.PUBLISH_VERSION ?? gitVersion;
46+
47+
if (isDryRun) {
48+
console.log(`Dry run publish detected; using version ${version}`);
49+
}
4150
try {
4251
await modifyPackageJson({ version });
4352
console.log('✅ Prepublish script completed successfully');

src/api.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import fs from 'fs';
2-
import path from 'path';
3-
import util from 'util';
41
import filesizeParser from 'filesize-parser';
52
import FormData from 'form-data';
3+
import fs from 'fs';
64
import fetch from 'node-fetch';
5+
import path from 'path';
76
import ProgressBar from 'progress';
87
import tcpp from 'tcp-ping';
8+
import util from 'util';
99
import { getBaseUrl } from 'utils/http-helper';
1010
import packageJson from '../package.json';
1111
import type { Package, Session } from './types';
12-
import { IS_CRESC, credentialFile, pricingPageUrl } from './utils/constants';
12+
import { credentialFile, IS_CRESC, pricingPageUrl } from './utils/constants';
1313
import { t } from './utils/i18n';
1414

1515
const tcpPing = util.promisify(tcpp.ping);
@@ -163,7 +163,6 @@ export async function uploadFile(fn: string, key?: string) {
163163
});
164164
let realUrl = url;
165165
if (backupUrl) {
166-
// @ts-ignore
167166
if (global.USE_ACC_OSS) {
168167
realUrl = backupUrl;
169168
} else {

src/app.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import fs from 'fs';
22
import Table from 'tty-table';
3-
import { question } from './utils';
4-
53
import { doDelete, get, post } from './api';
64
import type { Platform } from './types';
5+
import { question } from './utils';
76
import { t } from './utils/i18n';
87

98
interface AppSummary {

src/bundle-pack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from 'path';
21
import * as fs from 'fs-extra';
2+
import path from 'path';
33
import { ZipFile as YazlZipFile } from 'yazl';
44
import { t } from './utils/i18n';
55
import { zipOptionsForPayloadFile } from './utils/zip-options';

0 commit comments

Comments
 (0)