Skip to content

Commit 5f20f5f

Browse files
committed
fixes
1 parent e15144d commit 5f20f5f

File tree

4 files changed

+59
-151
lines changed

4 files changed

+59
-151
lines changed

.erb/scripts/upload-to-s3.py

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

.github/workflows/package.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ jobs:
1616
with:
1717
node-version: 20
1818
cache: npm
19-
20-
# - name: Recreate certificate.p12 from Base64
21-
# run: echo "${{ secrets.CSC_BASE64_ENCODED }}" | base64 -d > certificate.p12
22-
2319
- name: npm install
2420
run: |
2521
npm install
2622
27-
- name: Package
23+
- name: Package and Upload to S3
2824
env:
2925
APPLE_ID: ${{ secrets.APPLE_ID }}
3026
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
@@ -55,7 +51,7 @@ jobs:
5551
run: |
5652
npm install
5753
58-
- name: Package
54+
- name: Package and Upload to S3
5955
run: |
6056
npm run package-publish
6157
env:
@@ -80,7 +76,7 @@ jobs:
8076
run: |
8177
npm install
8278
83-
- name: Package
79+
- name: Package and Upload to S3
8480
run: |
8581
npm run package-publish
8682
env:

README.md

Lines changed: 56 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -239,50 +239,62 @@ certificate.p12
239239
base64 -i certificate.p12
240240
```
241241

242-
**2. Create S3 Bucket**
243-
1. Open AWS Console > S3.
242+
**2. Create an S3 Bucket**
243+
1. Open the AWS Console > S3.
244244
2. Click "Create bucket".
245245
3. Configure the bucket:
246246
```
247247
Bucket name: Enter a unique bucket name in kebab case (e.g., my-app-name-distribution)
248+
Object Ownership: Select ACLs enabled
248249
Block Public Access settings for this bucket: Uncheck "Block all public access"
249250
```
251+
*Important Note:*
252+
Ensure that **Object Ownership** is set to **"ACLs enabled"** because Electron Builder requires this setting to successfully upload files. Without it, you will encounter the following error:
253+
254+
**"The Bucket does not allow ACLs."**
255+
256+
![ACL Error](https://raw.githubusercontent.com/omkarcloud/macos-code-signing-example/master/images/acl-error.png)
257+
250258
4. Click on "Create bucket".
251-
5. Go to the bucket.
252-
6. Enable public access:
253-
- Go to the "Permissions" tab.
254-
- In the "Bucket policy" section, press the "Edit" button and paste the following policy (replace "<bucket-name>" with the bucket name you just created):
255-
```json
256-
{
257-
"Version": "2008-10-17",
258-
"Statement": [
259-
{
260-
"Sid": "AllowPublicRead",
261-
"Effect": "Allow",
262-
"Principal": {
263-
"AWS": "*"
264-
},
265-
"Action": "s3:GetObject",
266-
"Resource": "arn:aws:s3:::<bucket-name>/*"
267-
}
268-
]
269-
}
270-
```
271-
If you don't have them, then get AWS access key and secret key.
259+
260+
5. If you don't have an AWS access key and secret key, get them.
272261

273262
**3. Configure GitHub Secrets**
274263
In your GitHub Repository, navigate to Settings > Secrets and variables > Actions and add the following secrets:
275264
```
276265
APPLE_ID # Your Apple ID email
277266
APPLE_APP_SPECIFIC_PASSWORD # App Specific password
278267
APPLE_TEAM_ID # Your Team ID
279-
CSC_BASE64_ENCODED # Your Base64 encoded certificate created earlier
268+
CSC_LINK # Your Base64 encoded certificate created earlier
280269
CSC_KEY_PASSWORD # Certificate password
281270
AWS_ACCESS_KEY_ID # AWS access key
282271
AWS_SECRET_ACCESS_KEY # AWS secret key
283272
```
284273

285-
**4. Set up GitHub Actions**
274+
**4. Configure Electron Builder**
275+
1. In your "package.json" file, add the following to the Electron "build" configuration:
276+
```json
277+
"build": {
278+
"publish": {
279+
"provider": "s3",
280+
"bucket": "your-s3-bucket-name"
281+
}
282+
}
283+
```
284+
Replace "your-s3-bucket-name" with the name of your S3 bucket.
285+
286+
2. Add a new script called "package-publish" to the "scripts" section of your "package.json" file:
287+
```json
288+
{
289+
"scripts": {
290+
"package-publish": "ANY_PRE_BUILD_STEPS && electron-builder build --publish always && ANY_POST_BUILD_STEPS"
291+
}
292+
}
293+
```
294+
295+
Replace ANY_PRE_BUILD_STEPS and ANY_POST_BUILD_STEPS with your pre and post-build steps, if you have any. If you don't have any, remove them.
296+
297+
**5. Set up GitHub Actions**
286298
Create a `.github/workflows/package.yaml` file with the following contents:
287299
```yaml
288300
name: Package
@@ -303,34 +315,22 @@ jobs:
303315
with:
304316
node-version: 20
305317
cache: npm
306-
307-
- name: Recreate certificate.p12 from Base64
308-
run: echo "${{ secrets.CSC_BASE64_ENCODED }}" | base64 -d > certificate.p12
309-
310318
- name: npm install
311319
run: |
312320
npm install
313321
314-
- name: Package
322+
- name: Package and Upload to S3
315323
env:
316324
APPLE_ID: ${{ secrets.APPLE_ID }}
317325
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
318326
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
319-
CSC_LINK: ./certificate.p12
327+
CSC_LINK: ${{ secrets.CSC_LINK }}
320328
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
321-
run: |
322-
npm run package
323-
324-
- name: Install packages needed for S3 upload
325-
run: |
326-
python -m pip install botasaurus boto3
327-
328-
- name: Upload to S3
329-
env:
330329
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
331330
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
332331
run: |
333-
python .erb/scripts/upload-to-s3.py
332+
npm run package-publish
333+
334334
335335
package-windows:
336336
timeout-minutes: 30
@@ -350,20 +350,12 @@ jobs:
350350
run: |
351351
npm install
352352
353-
- name: Package
353+
- name: Package and Upload to S3
354354
run: |
355-
npm run package
356-
357-
- name: Install botasaurus package
358-
run: |
359-
python -m pip install botasaurus boto3
360-
361-
- name: Upload to S3
355+
npm run package-publish
362356
env:
363357
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
364358
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
365-
run: |
366-
python .erb/scripts/upload-to-s3.py
367359

368360
package-linux:
369361
timeout-minutes: 30
@@ -383,67 +375,24 @@ jobs:
383375
run: |
384376
npm install
385377
386-
- name: Package
387-
run: |
388-
npm run package
389-
390-
- name: Install packages needed for S3 upload
378+
- name: Package and Upload to S3
391379
run: |
392-
python -m pip install botasaurus boto3
393-
394-
- name: Upload to S3
380+
npm run package-publish
395381
env:
396382
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
397-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
398-
run: |
399-
python .erb/scripts/upload-to-s3.py
400-
```
401-
402-
**5. Create Upload Script**
403-
Create a `scripts/upload-to-s3.py` file with the following content. Replace "MY_BUCKET_NAME" with your bucket name:
404-
```python
405-
from botasaurus import bt
406-
from botasaurus.env import get_os
407-
from botasaurus.task import task
408-
import os
409-
410-
bucket_name = "MY_BUCKET_NAME"
411-
412-
@task(output=None, raise_exception=True, close_on_crash=True, parallel=4)
413-
def upload(data):
414-
upload_file_name = bt.trim_and_collapse_spaces(os.path.basename(data)).replace(' ','')
415-
416-
uploaded_file_url = bt.upload_to_s3(
417-
data,
418-
bucket_name,
419-
os.environ['AWS_ACCESS_KEY_ID'],
420-
os.environ['AWS_SECRET_ACCESS_KEY'],
421-
upload_file_name,
422-
)
423-
424-
print(f"Visit {uploaded_file_url} to download the uploaded file.") # URL to share with users
425-
426-
app_name = bt.read_json('./package.json')['build']['productName']
427-
operating_system = get_os()
428-
429-
if operating_system == "mac":
430-
upload(f"./release/build/{app_name}.dmg")
431-
elif operating_system == "windows":
432-
upload(f"./release/build/{app_name}.exe")
433-
elif operating_system == "linux":
434-
upload(
435-
[
436-
f"./release/build/{app_name}-amd64.deb",
437-
f"./release/build/{app_name}-arm64.deb",
438-
f"./release/build/{app_name}-x86_64.rpm",
439-
f"./release/build/{app_name}-aarch64.rpm",
440-
]
441-
)
383+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
442384
```
443385
444386
**6. Deploy**
445387
1. Push the code to GitHub.
446-
2. Go to the Repository "Actions" tab to see the build process in action.
447-
3. Once successfully completed, the URL to the uploaded file will be displayed in the logs of the "Upload to S3" section.
448-
4. Share the URL with your users to distribute the signed and notarized executable. Hurray! 🎉
388+
2. Go to the repository's "Actions" tab to see the build process in action.
389+
3. After a successful build, the installer files will be found in your S3 bucket. These files will be publicly accessible in the following format:
390+
```
391+
https://<your-bucket-name>.s3.amazonaws.com/<your-product-name>.dmg
392+
```
393+
394+
Examples:
395+
- https://awesome-app-distribution.s3.amazonaws.com/ElectronReact.dmg
396+
- https://awesome-app-distribution.s3.amazonaws.com/Awesome+App.dmg
449397

398+
4. Share the URL with your users to download the signed and notarized executable. Hurray! 🎉

images/acl-error.png

467 KB
Loading

0 commit comments

Comments
 (0)