Repository navigation
105 lines (90 loc) · 2.99 KB
/
Copy pathbuild-pr-plugin-platform.yml
File metadata and controls
105 lines (90 loc) · 2.99 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
name: Build PR Plugin Package Platform
on:
workflow_call:
inputs:
pr_number:
required: true
type: string
base_ref:
required: true
type: string
base_sha:
required: true
type: string
head_sha:
required: true
type: string
platform_name:
required: true
type: string
runner:
required: true
type: string
jobs:
build:
runs-on: ${{ inputs.runner }}
steps:
- name: Checkout PR code
shell: bash
env:
PR_NUMBER: ${{ inputs.pr_number }}
BASE_REF: ${{ inputs.base_ref }}
BASE_SHA: ${{ inputs.base_sha }}
HEAD_SHA: ${{ inputs.head_sha }}
REPOSITORY: ${{ github.repository }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${REPOSITORY}.git"
git fetch --no-tags --filter=blob:none origin \
"+${BASE_SHA}:refs/remotes/origin/pr-base" \
"+${HEAD_SHA}:refs/remotes/origin/pr-head"
git checkout --force --detach refs/remotes/origin/pr-base
if ! git \
-c user.name=github-actions \
-c user.email=github-actions@github.com \
merge --no-commit --no-ff refs/remotes/origin/pr-head; then
echo "::error::PR #${PR_NUMBER} 无法合并到 ${BASE_REF}@${BASE_SHA},请先解决与目标分支的冲突"
git status --short
exit 1
fi
git clean -ffdx
echo "Prepared PR #${PR_NUMBER}: ${HEAD_SHA} on ${BASE_REF}@${BASE_SHA}"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 10.5.0
- name: Download build info
uses: actions/download-artifact@v4
with:
name: pr-${{ inputs.pr_number }}-build-info
path: release
- name: Select platform build info
run: |
node -e "const fs = require('fs'); fs.copyFileSync('release/build-info.${{ inputs.platform_name }}.json', 'release/build-info.json')"
- name: Detect build requirements
id: build-requirements
run: node scripts/detect-build-requirements.js
- name: Setup Bun
if: steps.build-requirements.outputs.needs_bun == 'true'
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version-file: .bun-version
- name: Install root dependencies
run: npm ci
- name: Build changed plugins
run: node scripts/build-plugins.js
- name: Upload plugin packages
uses: actions/upload-artifact@v4
with:
name: pr-${{ inputs.pr_number }}-${{ inputs.platform_name }}-plugin-packages
path: |
release/*.zip
release/build-info.json
release/latest
if-no-files-found: error
retention-days: 14