diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ed4433..8d80627 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,25 +15,56 @@ jobs: mkdir dist/ python3 dev_tools/build_zip_dist.py . dist/GWARipper-${{github.ref_name}}.zip - # output will be in src/dist/windows + - name: Get date + run: echo "date_year=$(date +'%Y')" >> "$GITHUB_ENV" + + - name: Cache binary deps + id: cache-binary-deps + uses: actions/cache@v3 + with: + path: binary_deps/ + key: ${{ runner.os }}-build-${{ env.date_year }} + restore-keys: | + ${{ runner.os }}-build-${{ env.date_year }} + ${{ runner.os }}-build- + ${{ runner.os }}- + + # only download deps if we don't have a cached version + - if: ${{ steps.cache-binary-deps.outputs.cache-hit != 'true' }} + name: Download binary deps Windows + run: | + mkdir binary_deps + wget -O ffmpeg.zip https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip + unzip ffmpeg.zip -d binary_deps/ + find binary_deps/ffmpeg*-essentials_build/ -name ffmpeg.exe -exec cp {} binary_deps/ \; + rm -rf binary_deps/ffmpeg*-essentials_build/ + rm ffmpeg.zip + + # output (dir named 'gwaripper') will be in dist/windows - name: Package Application on Windows uses: JackMcKew/pyinstaller-action-windows@main with: path: . spec: gwaripper.spec - - name: Rename output Windows - run: mv src/dist/windows src/dist/GWARipper-${{github.ref_name}}_single-folder_win-x64 + - name: Bundle Windows + run: | + pushd dist/windows/gwaripper + zip -r ../../GWARipper-${{github.ref_name}}_single-folder_win-x64.zip . + popd - # output will be in src/dist/linux + # output (dir named 'gwaripper') will be in dist/linux - name: Package Application on Linux uses: JackMcKew/pyinstaller-action-linux@main with: path: . spec: gwaripper.spec - - name: Rename output Linux - run: mv src/dist/linux src/dist/GWARipper-${{github.ref_name}}_single-folder_lin-x64 + - name: Bundle Linux + run: | + pushd dist/linux/gwaripper + zip -r ../../GWARipper-${{github.ref_name}}_single-folder_lin-x64.zip . + popd - name: Release uses: softprops/action-gh-release@v1 @@ -42,5 +73,5 @@ jobs: generate_release_notes: true files: | dist/GWARipper-${{github.ref_name}}.zip - src/dist/GWARipper-${{github.ref_name}}_single-folder_win-x64 - src/dist/GWARipper-${{github.ref_name}}_single-folder_lin-x64 + dist/GWARipper-${{github.ref_name}}_single-folder_win-x64.zip + dist/GWARipper-${{github.ref_name}}_single-folder_lin-x64.zip diff --git a/gwaripper.spec b/gwaripper.spec index 682a2b2..df4d8d9 100644 --- a/gwaripper.spec +++ b/gwaripper.spec @@ -1,7 +1,24 @@ # -*- mode: python -*- +import os +from sys import platform block_cipher = None +data_files = [ + # praw needs praw.ini (which it looks for in 3 places appdata etc. including cwd) + # -> pyinstaller automatically changes __file__ refs to be relative to the bundle + # praw was looking praw.ini in ./praw/ because thats were the __file__ presumably + # was + ("praw.ini", "praw/"), + # also include webgui files + ("gwaripper_webGUI/static", "static"), + ("gwaripper_webGUI/templates", "templates"), + ("gwaripper/migrations/*.py", "gwaripper/migrations"), +] + +if platform == "win32" and os.path.exists(os.path.join("binary_deps", "ffmpeg.exe")): + data_files.append(("binary_deps/ffmpeg.exe", "./")) + # IMPORTANT: pyinstaller will apparently just bundle everything it finds in the current python # env so use a venv with only the required additional packages installed # pyinstaller needs to be installed in the venv as well and then started (on Win) using @@ -9,18 +26,7 @@ block_cipher = None a = Analysis(['gwaripper-runner.py'], pathex=['gwaripper', 'gwaripper_webGUI'], binaries=[], - # praw needs praw.ini (which it looks for in 3 places appdata etc. including cwd) - # -> pyinstaller automatically changes __file__ refs to be relative to the bundle - # praw was looking praw.ini in ./praw/ because thats were the __file__ presumably - # was - datas=[ - ("venv/Lib/site-packages/praw/praw.ini", "praw/"), - # also include webgui files - ("gwaripper_webGUI/static", "static"), - ("gwaripper_webGUI/templates", "templates"), - ("gwaripper/migrations/*.py", "gwaripper/migrations"), - ("binary_deps/ffmpeg.exe", "./"), - ], + datas=data_files, hiddenimports=[], hookspath=[], runtime_hooks=[], diff --git a/praw.ini b/praw.ini new file mode 100644 index 0000000..e3f4b17 --- /dev/null +++ b/praw.ini @@ -0,0 +1,26 @@ +[DEFAULT] +# A boolean to indicate whether or not to check for package updates. +check_for_updates=True + +# Object to kind mappings +comment_kind=t1 +message_kind=t4 +redditor_kind=t2 +submission_kind=t3 +subreddit_kind=t5 +trophy_kind=t6 + +# The URL prefix for OAuth-related requests. +oauth_url=https://oauth.reddit.com + +# The amount of seconds of ratelimit to sleep for upon encountering a specific type of 429 error. +ratelimit_seconds=5 + +# The URL prefix for regular requests. +reddit_url=https://www.reddit.com + +# The URL prefix for short URLs. +short_url=https://redd.it + +# The timeout for requests to Reddit in number of seconds +timeout=16