Skip to content

Commit

Permalink
feat: Add option to not add electron
Browse files Browse the repository at this point in the history
  • Loading branch information
dusansimic committed Feb 17, 2024
1 parent ed3a3bf commit ad95a37
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/notion-repackaged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,19 @@ jobs:
name: Build app
needs: [prepare-sources]
runs-on: ubuntu-latest
strategy:
matrix:
add_electron: [true, false]
suffix: ["-electron", ""]
exclude:
- add_electron: true
suffix: ""
- add_electron: false
suffix: "-electron"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
if: matrix.add_electron
with:
node-version: 18
- name: Retrieve saved sources
Expand All @@ -53,12 +63,16 @@ jobs:
run: mkdir work && tar -xf src.tar.xz -C work
- name: Build app
working-directory: scripts
env:
ADD_ELECTRON: ${{ matrix.add_electron }}
run: bash build-app.sh
- name: Package app
working-directory: scripts
env:
SUFFIX: ${{ matrix.suffix }}
run: bash package-app.sh
- name: Calculate checksum
run: sha256sum notion-app.tar.xz
run: sha256sum notion-app${{ matrix.suffix }}.tar.xz > notion-app${{ matrix.suffix }}.checksum

cleanup:
name: Cleanup artifacts
Expand Down
16 changes: 12 additions & 4 deletions scripts/build-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ install -d "${PKGDIR}${BINDIR}"
install -d "${PKGDIR}${DATADIR}"
install -d "${PKGDIR}${LIBDIR}"

log "Install electron..."
install -d "${PKGDIR}${LIBDIR}/electron"
npm install --prefix "${PKGDIR}${LIBDIR}/electron" electron@28
if [ "${ADD_ELECTRON}" = "true" ]
then
log "Installing electron..."
install -d "${PKGDIR}${LIBDIR}/electron"
npm install --prefix "${PKGDIR}${LIBDIR}/electron" electron@28
fi

pushd "${SRCDIR}/notion" > /dev/null

Expand All @@ -25,7 +28,12 @@ cp -a unpacked/{package.json,node_modules,.webpack} "${PKGDIR}${LIBDIR}"

log "Installing and patching run script..."
install -Dm755 "${BASEDIR}/sources/notion-app" -t "${PKGDIR}${BINDIR}"
sed -i "s~@electron@~${LIBDIR}/electron/node_modules/.bin/electron~g" "${PKGDIR}${BINDIR}/notion-app"
if [ "${ADD_ELECTRON}" = "true" ]
then
sed -i "s~@electron@~${LIBDIR}/electron/node_modules/.bin/electron~g" "${PKGDIR}${BINDIR}/notion-app"
else
log "Not adding electron... skipping patching step..."
fi

log "Installing icons and desktop file..."
install -Dm644 "${BASEDIR}/sources/notion-app.desktop" -t "${PKGDIR}${DATADIR}/applications"
Expand Down
8 changes: 7 additions & 1 deletion scripts/package-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ set -e
source _envs.sh
source _utils.sh

if [ -z "$SUFFIX" ]
then
log "SUFFIX for package archive is not defined!"
exit 1
fi

pushd "${BASEDIR}" > /dev/null

log "Create .tar.xz archive..."
tar -cJf notion-app.tar.xz --transform 's~^~notion-app/~' tools -C "${WORKDIR}" pkg
tar -cJf "notion-app${SUFFIX}.tar.xz" --transform 's~^~notion-app/~' tools -C "${WORKDIR}" pkg

popd > /dev/null

0 comments on commit ad95a37

Please sign in to comment.