Skip to content

Commit 99906b5

Browse files
committed
build: add github actions workflow and docs
1 parent 0a40f92 commit 99906b5

File tree

4 files changed

+108
-5
lines changed

4 files changed

+108
-5
lines changed

.github/workflows/decrypt_secret.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
# --batch to prevent interactive command
4+
# --yes to assume "yes" for questions
5+
6+
gpg --quiet --batch --yes --decrypt --passphrase="$PROVISION_PROFILE_PASSPHRASE" \
7+
--output ./assets/embedded.provisionprofile ./assets/embedded.provisionprofile.gpg

.github/workflows/release.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build/release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
jobs:
10+
release:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
matrix:
15+
os: [macos-latest, ubuntu-latest, windows-latest]
16+
17+
steps:
18+
- name: Check out Git repository
19+
uses: actions/checkout@v1
20+
21+
- name: Install Node.js, NPM and Yarn
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: 12
25+
26+
- name: Setup provision profile
27+
run: ./.github/workflows/decrypt_secret.sh
28+
env:
29+
PROVISION_PROFILE_PASSPHRASE: ${{ secrets.PROVISION_PROFILE_PASSPHRASE }}
30+
31+
- name: Yarn install
32+
run: yarn install --network-timeout 1000000 # allows to run without network error
33+
34+
# - name: build
35+
# run: yarn build:github
36+
# env:
37+
# REACT_APP_GRAASP_API_HOST: ${{secrets.REACT_APP_GRAASP_API_HOST}}
38+
# REACT_APP_GRAASP_HOST: ${{secrets.REACT_APP_GRAASP_HOST}}
39+
# GOOGLE_API_KEY: ${{secrets.GOOGLE_API_KEY}}
40+
41+
- name: Build/release Electron app
42+
uses: samuelmeuli/action-electron-builder@v1
43+
env:
44+
REACT_APP_GRAASP_API_HOST: ${{secrets.REACT_APP_GRAASP_API_HOST}}
45+
REACT_APP_GRAASP_HOST: ${{secrets.REACT_APP_GRAASP_HOST}}
46+
GOOGLE_API_KEY: ${{secrets.GOOGLE_API_KEY}}
47+
with:
48+
build_script_name: build:github
49+
# GitHub token, automatically provided to the action
50+
# (No need to define this secret in the repo settings)
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
53+
# If the commit is tagged with a version (e.g. "v1.0.0"),
54+
# release the app after building
55+
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
56+
mac_certs: ${{ secrets.mac_certs }}
57+
mac_certs_password: ${{ secrets.mac_certs_password }}

README.md

+41-4
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,53 @@ Following the `electron-log` defaults, logs are written to the following locatio
149149

150150
## Deploy and Publish
151151

152-
**Note**: MacOS can compile the desktop application for every other platforms. Windows OS can only compile Windows executable files.
153-
154152
### Requirements
155153

156154
- You should try to update all dependencies, particularly any dependencies related to `electron` and `electron-builder` as this dependency will create the executable files for every OS.
157-
- Make sure your `.env` and `.env.test` files contain the correct values. Use your own github token `GH_TOKEN` in order to release the new version with your github account.
155+
- Make sure your `.env` and `.env.test` files contain the correct values. Use your own github token `GH_TOKEN` in order to release the new version with your github account. If you are using the Github Actions, make sure the sensitive data are reported to Github's `Secrets` and are input in the corresponding workflow.
158156
- **Sign Apple executable files**: In order to sign the application and publish it on the mac store, you will need a corresponding **Developer ID** certificate installed on your apple computer. You need to be part of the apple developer team on the [Apple Developers Website](https://developer.apple.com/) as well as use the certificate containing the private key. [Here](https://help.apple.com/xcode/mac/current/#/dev154b28f09) you can find some indications to help you install this certificate. Once added to _Xcode_ (the should also be available in _My Certificates_ in Keychain), this certificate will be automatically be used during the creation of the executable files. You will also need the `assets/embedded.provisionprofile` file.
159157
This command will tell you if your app was correctly signed: `codesign --display --verbose=2 dist/mac/Graasp.app`
160158

161-
### Steps
159+
**Note**: MacOS can compile the desktop application for every other platforms. Windows OS can only compile Windows executable files.
160+
161+
### Github Actions Release
162+
163+
The whole process is handled in Github Actions, which is triggered for each push in a tag release. The next section will go through the steps for setting up this workflow, while the following sections will describe how to deploy and publish manually.
164+
165+
The workflow publishing the release on github is located at `.github/workflows/release.yml`. This workflow uses an [electron-builder action](https://github.com/samuelmeuli/action-electron-builder) which generates a release draft. Each platform (Windows, MacOS and Linux) generates its own executable to be added to the corresponding release.
166+
167+
The workflow takes as environment variable:
168+
169+
- the Application Developer ID certificate (to sign mac executables)
170+
- the certificate password
171+
- the provision profile passphrase
172+
- other necessary environment variables such endpoints, google api key, etc...
173+
174+
#### Environment Variables
175+
176+
Github Actions uses environment variables as `secrets`. These are set in `Settings → Secrets`, and then reported in the workflow under `env` with the following syntax:
177+
178+
```
179+
- name: your step's name
180+
run: commands
181+
env:
182+
YOUR_ENV_VARIABLE_NAME: ${{secrets.YOUR_SECRET_NAME}}
183+
```
184+
185+
#### Mac Signing
186+
187+
1. Export the necessary certificates as one file (eg `certs.p12`). This will ask for a password.
188+
2. Run `base64 -i certs.p12 -o encoded.txt`
189+
3. In your project's GitHub repository, go to `Settings → Secrets` and add the following two variables:
190+
191+
- `MAC_CERTS`: Your encoded certificates, i.e. the content of the encoded.txt file you created before
192+
- `MAC_CERTS_PASSWORD`: The password you set when exporting the certificates
193+
194+
4. The `embedded.provisionprofile` needs to be encrypted with gpg. Run `gpg -c embedded.provisionprofile`. Enter a password to validate the encryption.
195+
5. A new `embedded.provisionprofile.gpg` should have been created. This file should be pushed in the repo in `assets`.
196+
6. The password used to encrypt the file should be added to `secrets` as `PROVISION_PROFILE_PASSPHRASE`
197+
198+
### Manual Release Steps
162199

163200
1. Run `yarn dist`. This command will first build the repository and compile it into multiple executable files. All the configuration is set in `package.json`.
164201

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"scripts": {
3131
"dev": "yarn react-scripts start",
3232
"build": "env-cmd -f ./.env react-scripts build",
33+
"build:github": "node scripts/setup.js && react-scripts build",
3334
"start": "concurrently \"env-cmd -f ./.env.local react-scripts start\" \"wait-on http://localhost:3000 && env-cmd -f ./.env.local electron .\"",
3435
"pack": "electron-builder --dir",
3536
"prestart": "env-cmd -f ./.env.local node scripts/setup.js",
@@ -53,7 +54,8 @@
5354
"dist:win:docker": "./scripts/buildWindowsWithDocker.sh",
5455
"dist:all": "run-s dist:posix dist:win",
5556
"release:manual": "run-s version dist:all",
56-
"release": "git fetch --tags && git add CHANGELOG.md && standard-version -a && env-cmd -f ./.env electron-builder -ml && env-cmd -f ./.env electron-builder -w --x64 --ia32",
57+
"release:tags": "git fetch --tags && git add CHANGELOG.md && standard-version -a",
58+
"release": "yarn release:tags && env-cmd -f ./.env electron-builder -ml && env-cmd -f ./.env electron-builder -w --x64 --ia32",
5759
"hooks:uninstall": "node node_modules/husky/husky.js uninstall",
5860
"hooks:install": "node node_modules/husky/husky.js install",
5961
"postinstall": "electron-builder install-app-deps",

0 commit comments

Comments
 (0)