Skip to content

Commit 03d2952

Browse files
committed
Another rework of the build script
1 parent 1a5c158 commit 03d2952

File tree

6 files changed

+62
-32
lines changed

6 files changed

+62
-32
lines changed

.github/workflows/notion-repackaged.yml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,54 @@ env:
1414
NOTION_REPACKAGED_DEBUG: true
1515

1616
jobs:
17+
preload-variables:
18+
name: Preload variables
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- id: preload-variables
23+
name: Load variables and set them as outputs
24+
run: |
25+
source notion-repackaged.env
26+
27+
echo "::set-output name=notion_version::$NOTION_VERSION"
28+
echo "::set-output name=notion_repackaged_revision::$NOTION_REPACKAGED_REVISION"
29+
echo "::set-output name=notion_download_hash::$NOTION_DOWNLOAD_HASH"
30+
echo "::set-output name=notion_enhancer_commit::$NOTION_ENHANCER_COMMIT"
31+
32+
NOTION_REPACKAGED_VERSION_REV="${NOTION_VERSION}-${NOTION_REPACKAGED_REVISION}"
33+
echo "::set-output name=notion_repackaged_version_rev::$NOTION_REPACKAGED_VERSION_REV"
34+
outputs:
35+
notion_version: ${{ steps.preload-variables.outputs.notion_version }}
36+
notion_repackaged_revision: ${{ steps.preload-variables.outputs.notion_repackaged_revision }}
37+
notion_repackaged_version_rev: ${{ steps.preload-variables.outputs.notion_repackaged_version_rev }}
38+
notion_download_hash: ${{ steps.preload-variables.outputs.notion_download_hash }}
39+
notion_enhancer_commit: ${{ steps.preload-variables.outputs.notion_enhancer_commit }}
40+
1741
create-release:
1842
name: Create release
1943
runs-on: ubuntu-latest
44+
needs: [preload-variables]
2045
steps:
2146
- uses: actions/checkout@v2
22-
- run: grep -v '^#' notion-repackaged.env >> $GITHUB_ENV
2347
- uses: release-drafter/release-drafter@v5
2448
env:
2549
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2650
with:
27-
version: "${{ env.NOTION_VERSION }}-${{ env.NOTION_REPACKAGED_REVISION }}"
51+
version: ${{ needs.preload-variables.outputs.notion_repackaged_version_rev }}
2852

2953
make-vanilla-sources:
3054
name: Make vanilla sources
3155
runs-on: ubuntu-latest
56+
needs: [preload-variables]
57+
env:
58+
NOTION_VERSION: ${{ needs.preload-variables.outputs.notion_version }}
59+
NOTION_REPACKAGED_REVISION: ${{ needs.preload-variables.outputs.notion_repackaged_revision }}
3260
steps:
3361
- uses: actions/checkout@v2
34-
- run: grep -v '^#' notion-repackaged.env >> $GITHUB_ENV
3562
- name: Download official Windows build
63+
env:
64+
NOTION_DOWNLOAD_HASH: ${{ needs.preload-variables.outputs.notion_download_hash }}
3665
run: scripts/download-exe.sh
3766
- name: Extract sources from Windows Build
3867
run: scripts/extract-src.sh
@@ -47,11 +76,10 @@ jobs:
4776

4877
make-enhanced-sources:
4978
name: Make enhanced sources
50-
needs: [make-vanilla-sources]
79+
needs: [make-vanilla-sources, preload-variables]
5180
runs-on: ubuntu-latest
5281
steps:
5382
- uses: actions/checkout@v2
54-
- run: grep -v '^#' notion-repackaged.env >> $GITHUB_ENV
5583
- name: Retrieve saved vanilla sources
5684
uses: actions/download-artifact@v2
5785
with:
@@ -63,6 +91,8 @@ jobs:
6391
- name: Install icnsutils
6492
run: sudo apt-get install -y icnsutils
6593
- name: Enhance extracted sources
94+
env:
95+
NOTION_ENHANCER_COMMIT: ${{ needs.preload-variables.outputs.notion_enhancer_commit }}
6696
run: scripts/enhance-src.sh
6797
- name: Zip sources dir with 7z
6898
working-directory: build
@@ -75,8 +105,11 @@ jobs:
75105

76106
build-app:
77107
name: Build app
78-
needs: [make-vanilla-sources, make-enhanced-sources, create-release]
108+
needs: [make-vanilla-sources, make-enhanced-sources, preload-variables]
79109
runs-on: ${{ matrix.os }}
110+
env:
111+
NOTION_VERSION: ${{ needs.preload-variables.outputs.notion_version }}
112+
NOTION_REPACKAGED_REVISION: ${{ needs.preload-variables.outputs.notion_repackaged_revision }}
80113
strategy:
81114
matrix:
82115
target: [windows, linux, macos]
@@ -95,7 +128,6 @@ jobs:
95128
edition: vanilla
96129
steps:
97130
- uses: actions/checkout@v2
98-
- run: grep -v '^#' notion-repackaged.env >> $GITHUB_ENV
99131
- uses: actions/setup-node@v1
100132
with:
101133
node-version: 14
@@ -123,8 +155,6 @@ jobs:
123155
env:
124156
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125157
NOTION_REPACKAGED_EDITION: ${{ matrix.edition }}
126-
NOTION_VERSION: ${{ env.NOTION_VERSION }}
127-
NOTION_REPACKAGED_REVISION: ${{ env.NOTION_REPACKAGED_REVISION }}
128158
run: npx electron-builder --${{ matrix.target }} -c ../electron-builder.js
129159

130160
cleanup:

scripts/_utils.sh

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ function log() {
66
}
77

88
function check-cmd() {
9-
if ! command -v $1 > /dev/null; then
10-
log "Missing required command dependency: $1"
11-
exit -1
12-
fi
9+
for cmd_name in "$@"; do
10+
if ! command -v ${cmd_name} > /dev/null; then
11+
log "Missing required command dependency: $1"
12+
exit -1
13+
fi
14+
done
1315
}
1416

1517
function check-env() {
1618
for var_name in "$@"; do
1719
if [ -z "${!var_name}" ]; then
18-
log "Required environment variable $var_name is not set"
20+
log "Missing required environment variable: $var_name"
1921
exit -1
2022
fi
2123
done
@@ -32,20 +34,12 @@ function check-debug-expands() {
3234
fi
3335
}
3436

35-
check-env NOTION_VERSION NOTION_REPACKAGED_REVISION NOTION_DOWNLOAD_HASH NOTION_ENHANCER_COMMIT
36-
37-
export NOTION_DOWNLOAD_URL="https://desktop-release.notion-static.com/Notion%20Setup%20${NOTION_VERSION}.exe"
38-
export NOTION_DOWNLOADED_NAME="Notion-${NOTION_VERSION}.exe"
39-
40-
41-
export NOTION_ENHANCER_REPO_URL="https://github.com/notion-enhancer/notion-enhancer"
4237
export NOTION_EXTRACTED_EXE_NAME="extracted-exe"
4338
export NOTION_EXTRACTED_APP_NAME="extracted-app"
4439
export NOTION_VANILLA_SRC_NAME="vanilla-src"
4540
export NOTION_ENHANCED_SRC_NAME="enhanced-src"
4641
export NOTION_EMBEDDED_NAME="embedded_enhancer"
4742

48-
export NOTION_REPACKAGED_VERSION_REV="${NOTION_VERSION}-${NOTION_REPACKAGED_REVISION}"
4943
export NOTION_REPACKAGED_HOMEPAGE="https://github.com/jamezrin/notion-repackaged"
5044
export NOTION_REPACKAGED_REPO=${NOTION_REPACKAGED_REPO:-${NOTION_REPACKAGED_HOMEPAGE}}
5145
export NOTION_REPACKAGED_AUTHOR="Notion Repackaged"

scripts/build-locally.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ source `dirname $0`/_utils.sh
55
check-debug-expands
66
workspace-dir-pushd
77

8-
check-cmd jq
9-
check-cmd git
8+
check-cmd jq git
9+
check-env NOTION_VERSION NOTION_REPACKAGED_REVISION
1010

1111
if [ -z "${NOTION_REPACKAGED_EDITION}" ]; then
1212
log "Cannot build without knowing the edition to build, please set NOTION_REPACKAGED_EDITION env var"

scripts/download-exe.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ source `dirname $0`/_utils.sh
55
check-debug-expands
66
workspace-dir-pushd
77

8-
check-cmd curl
8+
check-cmd curl md5sum
9+
check-env NOTION_VERSION NOTION_DOWNLOAD_HASH
10+
11+
export NOTION_DOWNLOAD_URL="https://desktop-release.notion-static.com/Notion%20Setup%20${NOTION_VERSION}.exe"
12+
export NOTION_DOWNLOADED_NAME="Notion-${NOTION_VERSION}.exe"
913

1014
if [ -f "${NOTION_DOWNLOADED_NAME}" ]; then
1115
log "Removing already downloaded file..."

scripts/enhance-src.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ source `dirname $0`/_utils.sh
55
check-debug-expands
66
workspace-dir-pushd
77

8-
check-cmd jq
9-
check-cmd git
10-
check-cmd convert
11-
check-cmd png2icns
8+
check-cmd jq git convert png2icns
9+
check-env NOTION_ENHANCER_COMMIT
1210

1311
if [ -d "${NOTION_ENHANCED_SRC_NAME}" ]; then
1412
log "Removing already enhanced sources..."
@@ -30,6 +28,7 @@ patch -p0 --binary < "${WORKSPACE_DIR}/patches/notion-check-relativeurl.patch"
3028

3129
log "Fetching enhancer sources..."
3230

31+
export NOTION_ENHANCER_REPO_URL="https://github.com/notion-enhancer/notion-enhancer"
3332
git clone "${NOTION_ENHANCER_REPO_URL}" "${NOTION_EMBEDDED_NAME}"
3433

3534
pushd "${NOTION_EMBEDDED_NAME}" > /dev/null

scripts/extract-src.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ source `dirname $0`/_utils.sh
55
check-debug-expands
66
workspace-dir-pushd
77

8-
check-cmd 7z
9-
check-cmd jq
10-
check-cmd convert
8+
check-cmd 7z jq convert
9+
check-env NOTION_VERSION NOTION_REPACKAGED_REVISION
1110

1211
if [ -d "${NOTION_EXTRACTED_EXE_NAME}" ]; then
1312
log "Removing already extracted exe contents..."
1413
rm -r "${NOTION_EXTRACTED_EXE_NAME}"
1514
fi
1615

16+
export NOTION_DOWNLOADED_NAME="Notion-${NOTION_VERSION}.exe"
1717
log "Extracting Windows installer contents..."
18+
1819
7z x -y "${NOTION_DOWNLOADED_NAME}" \
1920
-o"${NOTION_EXTRACTED_EXE_NAME}" > /dev/null
2021

@@ -38,6 +39,8 @@ cp -r "${NOTION_EXTRACTED_APP_NAME}/resources/app/"* "${NOTION_VANILLA_SRC_NAME}
3839

3940
pushd "${NOTION_VANILLA_SRC_NAME}" > /dev/null
4041

42+
export NOTION_REPACKAGED_VERSION_REV="${NOTION_VERSION}-${NOTION_REPACKAGED_REVISION}"
43+
4144
log "Patching source for fixes..."
4245
sed -i 's|process.platform === "win32"|process.platform !== "darwin"|g' main/main.js
4346
PATCHED_PACKAGE_JSON=$(jq \

0 commit comments

Comments
 (0)