-
Notifications
You must be signed in to change notification settings - Fork 704
159 lines (140 loc) · 5.65 KB
/
pull-request-build.yml
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
name: Build pull request artifacts
on:
pull_request:
branches:
- master
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
build:
if: contains(github.event.pull_request.labels.*.name, 'build-artifacts')
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Disable git core.autocrlf
run: git config --global core.autocrlf false
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node 20.14.0
uses: actions/setup-node@v4
with:
node-version: '20.14.0'
- name: Setup node_modules cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install package dependencies
run: yarn install
- name: Lint
run: yarn lint
- name: Test
run: yarn test
- name: Build app/
run: yarn build
env:
NODE_ENV: production
BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }}
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
- name: Build Windows Package
if: ${{ matrix.os == 'windows-latest' }}
run: yarn electron-builder --publish never --x64 --win nsis
env:
CSC_LINK: ${{ secrets.WIN_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
- name: Build MacOS Package
if: ${{ matrix.os == 'macos-latest' }}
run: |
sudo mdutil -a -i off
yarn electron-builder --publish never --mac --universal
env:
CSC_LINK: ${{ secrets.MAC_CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.MAC_CSC_KEY_PASSWORD }}
CSC_FOR_PULL_REQUEST: true
FORCE_NOTARIZE: true
APPLEID: ${{ secrets.APPLEID }}
APPLEIDPASS: ${{ secrets.APPLEIDPASS }}
ASC_PROVIDER: 'S6UPZG7ZR3'
- name: Build Ubuntu Package
if: ${{ matrix.os == 'ubuntu-latest' }}
run: yarn electron-builder --publish never --linux snap
# Install AWS CLI
- name: Install AWS CLI
run: pip install awscli
# Upload artifacts to Wasabi (Windows)
- name: Upload Artifacts to Wasabi (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
aws s3 cp dist/ s3://${{ secrets.WASABI_BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/${{ matrix.os }}/ --recursive `
--acl public-read `
--endpoint-url=https://s3.us-east-1.wasabisys.com `
--exclude "*" `
--include "rocketchat-*.exe"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.WASABI_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.WASABI_SECRET_ACCESS_KEY }}
# Upload artifacts to Wasabi (macOS)
- name: Upload Artifacts to Wasabi (macOS)
if: ${{ matrix.os == 'macos-latest' }}
run: |
aws s3 cp dist/ s3://${{ secrets.WASABI_BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/${{ matrix.os }}/ --recursive \
--acl public-read \
--endpoint-url=https://s3.us-east-1.wasabisys.com \
--exclude "*" \
--include "rocketchat-*.dmg" \
--include "rocketchat-*.pkg"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.WASABI_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.WASABI_SECRET_ACCESS_KEY }}
# Upload artifacts to Wasabi (Ubuntu)
- name: Upload Artifacts to Wasabi (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
aws s3 cp dist/ s3://${{ secrets.WASABI_BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/${{ matrix.os }}/ --recursive \
--acl public-read \
--endpoint-url=https://s3.us-east-1.wasabisys.com \
--exclude "*" \
--include "rocketchat-*.snap"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.WASABI_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.WASABI_SECRET_ACCESS_KEY }}
# Get Artifact URLs using actions/github-script (only specified file extensions)
- name: Get Artifact URLs
id: get-artifact-urls
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const path = require('path');
const distDir = path.join(process.cwd(), 'dist');
const files = fs.readdirSync(distDir);
const patterns = [/rocketchat-.*\.dmg$/, /rocketchat-.*\.pkg$/, /rocketchat-.*\.exe$/, /rocketchat-.*\.snap$/];
let artifactUrls = '';
for (const file of files) {
if (patterns.some(pattern => pattern.test(file))) {
const artifactUrl = `https://s3.us-east-1.wasabisys.com/${{ secrets.WASABI_BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/${{ matrix.os }}/${file}`;
artifactUrls += `- [${file}](${artifactUrl})\n`;
}
}
core.setOutput('artifact_urls', artifactUrls.trim());
- name: Post PR Comment with the Artifact links
if: steps.get-artifact-urls.outputs.artifact_urls != ''
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: |
### ${{ runner.os }} installer download
${{ steps.get-artifact-urls.outputs.artifact_urls }}
header: '### ${{ runner.os }} installer download'
recreate: true
append: false