-
Notifications
You must be signed in to change notification settings - Fork 255
150 lines (130 loc) · 5.3 KB
/
Copy pathbuild_on_pr_label.yml
File metadata and controls
150 lines (130 loc) · 5.3 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
name: Test build on PR label
permissions:
id-token: write
contents: write
issues: write
pull-requests: write
on:
pull_request:
types: [labeled]
jobs:
prepare:
runs-on: ubuntu-22.04
if: contains(fromJSON('["pr-build-mac", "pr-build-mac-intel", "pr-build-win", "pr-build-linux"]'), github.event.label.name)
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
version_tag: ${{ steps.set-version-tag.outputs.VERSION_TAG }}
steps:
- id: set-matrix
run: |
matrix="{\"include\":["
if [[ "${{ github.event.label.name }}" == "pr-build-mac" ]]; then
matrix="$matrix{\"os\":\"macos-14\",\"architecture\":\"arm\",\"build_command\":\"yarn build:desktop:mac:arm\"},"
fi
if [[ "${{ github.event.label.name }}" == "pr-build-mac-intel" ]]; then
matrix="$matrix{\"os\":\"macos-14\",\"architecture\":\"arm\",\"build_command\":\"yarn build:desktop:mac:x64\"},"
fi
if [[ "${{ github.event.label.name }}" == "pr-build-win" ]]; then
matrix="$matrix{\"os\":\"windows-latest\",\"architecture\":\"x64\",\"build_command\":\"yarn build:desktop:win:x64\"},"
fi
if [[ "${{ github.event.label.name }}" == "pr-build-linux" ]]; then
matrix="$matrix{\"os\":\"ubuntu-22.04\",\"architecture\":\"x64\",\"build_command\":\"yarn build:desktop:lin:x64\"},"
fi
matrix="${matrix%,}]}"
echo "matrix=$matrix" >> $GITHUB_OUTPUT
- id: set-version-tag
run: |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c 1-7)
echo "VERSION_TAG=${{ github.head_ref }}-$SHORT_SHA" | sed 's/\//-/g' >> $GITHUB_OUTPUT
build:
needs: prepare
strategy:
matrix: ${{fromJson(needs.prepare.outputs.matrix)}}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24.13.1
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cache node_modules
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ matrix.architecture }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.architecture }}-node-
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: |
packages/backend
packages/backend-server
key: ${{ runner.os }}-${{ matrix.architecture }}-rust-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo-about binary
id: cache-cargo-about
uses: actions/cache@v3
with:
path: ~/.cargo/bin/cargo-about
key: ${{ runner.os }}-${{ matrix.architecture }}-cargo-about-0.8.2
- name: Install cargo-about
if: steps.cache-cargo-about.outputs.cache-hit != 'true'
run: cargo install cargo-about --version 0.8.2
- name: Install dependencies
run: |
yarn config set network-timeout 300000
yarn install --frozen-lockfile --network-timeout 300000
- name: Build for ${{ matrix.os }}-${{ matrix.architecture }}
run: ${{ matrix.build_command }}
env:
APP_VERSION: 0.0.1-${{ needs.prepare.outputs.version_tag }}
M_VITE_APP_VERSION: 0.0.1-${{ needs.prepare.outputs.version_tag }}
P_VITE_APP_VERSION: 0.0.1-${{ needs.prepare.outputs.version_tag }}
R_VITE_APP_VERSION: 0.0.1-${{ needs.prepare.outputs.version_tag }}
HUSKY: 0
NODE_OPTIONS: --max_old_space_size=8192
PRODUCT_NAME: 'Surf'
M_VITE_PRODUCT_NAME: 'Surf'
BUILD_RESOURCES_DIR: build/resources/dev
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ needs.prepare.outputs.version_tag }}-build-${{ matrix.os }}-${{ matrix.architecture }}
path: |
app/dist/*.dmg
app/dist/*.exe
app/dist/*.AppImage
app/dist/*.tar.gz
app/dist/surf-*.yml
comment-on-pr:
needs: [prepare, build]
runs-on: ubuntu-22.04
steps:
- name: Comment on Pull Request
uses: actions/github-script@v7
with:
script: |
const version = '${{ needs.prepare.outputs.version_tag }}';
const runId = context.runId;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId,
});
let artifactLinks = '';
for (const artifact of artifacts.data.artifacts) {
const downloadUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}/artifacts/${artifact.id}`;
artifactLinks += `- [${artifact.name}](${downloadUrl})\n`;
}
const body = `✅ Build completed successfully for version \`${version}\`\n\n**Download artifacts:**\n${artifactLinks}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});