diff --git a/.github/workflows/notion-repackaged.yml b/.github/workflows/notion-repackaged.yml index 7a109cd..b112b39 100644 --- a/.github/workflows/notion-repackaged.yml +++ b/.github/workflows/notion-repackaged.yml @@ -14,25 +14,54 @@ env: NOTION_REPACKAGED_DEBUG: true jobs: + preload-variables: + name: Preload variables + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - id: preload-variables + name: Load variables and set them as outputs + run: | + source notion-repackaged.env + + echo "::set-output name=notion_version::$NOTION_VERSION" + echo "::set-output name=notion_repackaged_revision::$NOTION_REPACKAGED_REVISION" + echo "::set-output name=notion_download_hash::$NOTION_DOWNLOAD_HASH" + echo "::set-output name=notion_enhancer_commit::$NOTION_ENHANCER_COMMIT" + + NOTION_REPACKAGED_VERSION_REV="${NOTION_VERSION}-${NOTION_REPACKAGED_REVISION}" + echo "::set-output name=notion_repackaged_version_rev::$NOTION_REPACKAGED_VERSION_REV" + outputs: + notion_version: ${{ steps.preload-variables.outputs.notion_version }} + notion_repackaged_revision: ${{ steps.preload-variables.outputs.notion_repackaged_revision }} + notion_repackaged_version_rev: ${{ steps.preload-variables.outputs.notion_repackaged_version_rev }} + notion_download_hash: ${{ steps.preload-variables.outputs.notion_download_hash }} + notion_enhancer_commit: ${{ steps.preload-variables.outputs.notion_enhancer_commit }} + create-release: name: Create release runs-on: ubuntu-latest + needs: [preload-variables] steps: - uses: actions/checkout@v2 - - run: grep -v '^#' notion-repackaged.env >> $GITHUB_ENV - uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: "${{ env.NOTION_VERSION }}-${{ env.NOTION_REPACKAGED_REVISION }}" + version: ${{ needs.preload-variables.outputs.notion_repackaged_version_rev }} make-vanilla-sources: name: Make vanilla sources runs-on: ubuntu-latest + needs: [preload-variables] + env: + NOTION_VERSION: ${{ needs.preload-variables.outputs.notion_version }} + NOTION_REPACKAGED_REVISION: ${{ needs.preload-variables.outputs.notion_repackaged_revision }} steps: - uses: actions/checkout@v2 - - run: grep -v '^#' notion-repackaged.env >> $GITHUB_ENV - name: Download official Windows build + env: + NOTION_DOWNLOAD_HASH: ${{ needs.preload-variables.outputs.notion_download_hash }} run: scripts/download-exe.sh - name: Extract sources from Windows Build run: scripts/extract-src.sh @@ -47,11 +76,10 @@ jobs: make-enhanced-sources: name: Make enhanced sources - needs: [make-vanilla-sources] + needs: [make-vanilla-sources, preload-variables] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: grep -v '^#' notion-repackaged.env >> $GITHUB_ENV - name: Retrieve saved vanilla sources uses: actions/download-artifact@v2 with: @@ -63,6 +91,8 @@ jobs: - name: Install icnsutils run: sudo apt-get install -y icnsutils - name: Enhance extracted sources + env: + NOTION_ENHANCER_COMMIT: ${{ needs.preload-variables.outputs.notion_enhancer_commit }} run: scripts/enhance-src.sh - name: Zip sources dir with 7z working-directory: build @@ -75,8 +105,11 @@ jobs: build-app: name: Build app - needs: [make-vanilla-sources, make-enhanced-sources, create-release] + needs: [make-vanilla-sources, make-enhanced-sources, preload-variables] runs-on: ${{ matrix.os }} + env: + NOTION_VERSION: ${{ needs.preload-variables.outputs.notion_version }} + NOTION_REPACKAGED_REVISION: ${{ needs.preload-variables.outputs.notion_repackaged_revision }} strategy: matrix: target: [windows, linux, macos] @@ -95,7 +128,6 @@ jobs: edition: vanilla steps: - uses: actions/checkout@v2 - - run: grep -v '^#' notion-repackaged.env >> $GITHUB_ENV - uses: actions/setup-node@v1 with: node-version: 14 @@ -123,8 +155,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NOTION_REPACKAGED_EDITION: ${{ matrix.edition }} - NOTION_VERSION: ${{ env.NOTION_VERSION }} - NOTION_REPACKAGED_REVISION: ${{ env.NOTION_REPACKAGED_REVISION }} run: npx electron-builder --${{ matrix.target }} -c ../electron-builder.js cleanup: diff --git a/scripts/_utils.sh b/scripts/_utils.sh index 7f3fa2b..31d5c15 100644 --- a/scripts/_utils.sh +++ b/scripts/_utils.sh @@ -6,16 +6,18 @@ function log() { } function check-cmd() { - if ! command -v $1 > /dev/null; then - log "Missing required command dependency: $1" - exit -1 - fi + for cmd_name in "$@"; do + if ! command -v ${cmd_name} > /dev/null; then + log "Missing required command dependency: $1" + exit -1 + fi + done } function check-env() { for var_name in "$@"; do if [ -z "${!var_name}" ]; then - log "Required environment variable $var_name is not set" + log "Missing required environment variable: $var_name" exit -1 fi done @@ -32,20 +34,12 @@ function check-debug-expands() { fi } -check-env NOTION_VERSION NOTION_REPACKAGED_REVISION NOTION_DOWNLOAD_HASH NOTION_ENHANCER_COMMIT - -export NOTION_DOWNLOAD_URL="https://desktop-release.notion-static.com/Notion%20Setup%20${NOTION_VERSION}.exe" -export NOTION_DOWNLOADED_NAME="Notion-${NOTION_VERSION}.exe" - - -export NOTION_ENHANCER_REPO_URL="https://github.com/notion-enhancer/notion-enhancer" export NOTION_EXTRACTED_EXE_NAME="extracted-exe" export NOTION_EXTRACTED_APP_NAME="extracted-app" export NOTION_VANILLA_SRC_NAME="vanilla-src" export NOTION_ENHANCED_SRC_NAME="enhanced-src" export NOTION_EMBEDDED_NAME="embedded_enhancer" -export NOTION_REPACKAGED_VERSION_REV="${NOTION_VERSION}-${NOTION_REPACKAGED_REVISION}" export NOTION_REPACKAGED_HOMEPAGE="https://github.com/jamezrin/notion-repackaged" export NOTION_REPACKAGED_REPO=${NOTION_REPACKAGED_REPO:-${NOTION_REPACKAGED_HOMEPAGE}} export NOTION_REPACKAGED_AUTHOR="Notion Repackaged" diff --git a/scripts/build-locally.sh b/scripts/build-locally.sh index ddac831..a4fadc8 100755 --- a/scripts/build-locally.sh +++ b/scripts/build-locally.sh @@ -5,8 +5,8 @@ source `dirname $0`/_utils.sh check-debug-expands workspace-dir-pushd -check-cmd jq -check-cmd git +check-cmd jq git +check-env NOTION_VERSION NOTION_REPACKAGED_REVISION if [ -z "${NOTION_REPACKAGED_EDITION}" ]; then log "Cannot build without knowing the edition to build, please set NOTION_REPACKAGED_EDITION env var" diff --git a/scripts/download-exe.sh b/scripts/download-exe.sh index 429afb7..c513fa9 100755 --- a/scripts/download-exe.sh +++ b/scripts/download-exe.sh @@ -5,7 +5,11 @@ source `dirname $0`/_utils.sh check-debug-expands workspace-dir-pushd -check-cmd curl +check-cmd curl md5sum +check-env NOTION_VERSION NOTION_DOWNLOAD_HASH + +export NOTION_DOWNLOAD_URL="https://desktop-release.notion-static.com/Notion%20Setup%20${NOTION_VERSION}.exe" +export NOTION_DOWNLOADED_NAME="Notion-${NOTION_VERSION}.exe" if [ -f "${NOTION_DOWNLOADED_NAME}" ]; then log "Removing already downloaded file..." diff --git a/scripts/enhance-src.sh b/scripts/enhance-src.sh index 685d3e4..140e382 100755 --- a/scripts/enhance-src.sh +++ b/scripts/enhance-src.sh @@ -5,10 +5,8 @@ source `dirname $0`/_utils.sh check-debug-expands workspace-dir-pushd -check-cmd jq -check-cmd git -check-cmd convert -check-cmd png2icns +check-cmd jq git convert png2icns +check-env NOTION_ENHANCER_COMMIT if [ -d "${NOTION_ENHANCED_SRC_NAME}" ]; then log "Removing already enhanced sources..." @@ -30,6 +28,7 @@ patch -p0 --binary < "${WORKSPACE_DIR}/patches/notion-check-relativeurl.patch" log "Fetching enhancer sources..." +export NOTION_ENHANCER_REPO_URL="https://github.com/notion-enhancer/notion-enhancer" git clone "${NOTION_ENHANCER_REPO_URL}" "${NOTION_EMBEDDED_NAME}" pushd "${NOTION_EMBEDDED_NAME}" > /dev/null diff --git a/scripts/extract-src.sh b/scripts/extract-src.sh index c9d62bc..e2b124d 100755 --- a/scripts/extract-src.sh +++ b/scripts/extract-src.sh @@ -5,16 +5,17 @@ source `dirname $0`/_utils.sh check-debug-expands workspace-dir-pushd -check-cmd 7z -check-cmd jq -check-cmd convert +check-cmd 7z jq convert +check-env NOTION_VERSION NOTION_REPACKAGED_REVISION if [ -d "${NOTION_EXTRACTED_EXE_NAME}" ]; then log "Removing already extracted exe contents..." rm -r "${NOTION_EXTRACTED_EXE_NAME}" fi +export NOTION_DOWNLOADED_NAME="Notion-${NOTION_VERSION}.exe" log "Extracting Windows installer contents..." + 7z x -y "${NOTION_DOWNLOADED_NAME}" \ -o"${NOTION_EXTRACTED_EXE_NAME}" > /dev/null @@ -38,6 +39,8 @@ cp -r "${NOTION_EXTRACTED_APP_NAME}/resources/app/"* "${NOTION_VANILLA_SRC_NAME} pushd "${NOTION_VANILLA_SRC_NAME}" > /dev/null +export NOTION_REPACKAGED_VERSION_REV="${NOTION_VERSION}-${NOTION_REPACKAGED_REVISION}" + log "Patching source for fixes..." sed -i 's|process.platform === "win32"|process.platform !== "darwin"|g' main/main.js PATCHED_PACKAGE_JSON=$(jq \