Skip to content

Merge branch 'main' into build #1

Merge branch 'main' into build

Merge branch 'main' into build #1

Workflow file for this run

name: Add built assets to latest release
on:
push:
permissions:
contents: write
jobs:
get_tag:
# get the latest tag (separate job as Windows doesn't support this method)
# straightforward because in this repository tags are used only for releases, but we could do a regex match if not
runs-on: ubuntu-latest
outputs:
output: ${{ steps.latest_tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
- id: latest_tag
run: |
git fetch -a
echo "tag=$(git tag --sort -committerdate | head -n 1)" >> $GITHUB_OUTPUT
build:
needs: get_tag
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
# install requirements
# - note: `imageio` is required here to convert our PNG icon to a format nuitka can handle (nuitka itself is a separate action)
# - note: `certifi` is required here because pyinstaller no longer bundles certificates (pyinstaller #7229)
# - note: `boto3`, `requests`, `google-auth` and corresponding pyinstaller hidden imports / nuitka included
# packages are so that advanced proxy features work in pre-built binaries
# - note: `--hidden-import timeago.locales.en_short` is required for GUI mode until `timeago` #40 is fixed
- run: |
python -m pip install --upgrade pip
python -m pip install wheel
python -m pip install pyinstaller imageio
python -m pip install -r requirements-core.txt -r requirements-gui.txt
python -m pip install certifi
python -m pip install boto3 requests google-auth
# build the pyinstaller version (same method for both macOS and Windows), outputting to the folder `dist`
- run: python -m PyInstaller --clean --noconsole --onefile --hidden-import prompt_toolkit --hidden-import timeago.locales.en_short --hidden-import certifi --hidden-import boto3 --hidden-import requests --hidden-import google --hidden-import jwt --icon icon.png --distpath dist/ emailproxy.py
# add license, documentation, configuration file sample and disclaimer
# - note: `move [...] alias move=mv [...]` is to support using the same commands on all platforms
- run: |
move LICENSE . 2> nul || { shopt -s expand_aliases; alias move=mv; }
move LICENSE dist/
move README.md dist/
move emailproxy.config dist/
echo 'This binary distribution is automatically created for each Email OAuth 2.0 Proxy release, ' >> _.txt
echo 'but is not tested, and is not officially supported. Using the main emailproxy.py script ' >> _.txt
echo 'directly is recommended for best results: https://github.com/simonrob/email-oauth2-proxy/' >> _.txt
move _.txt dist/GettingStarted.txt
# on macOS pyinstaller `--onefile` creates bundle *and* binary; we don't need both (and the .app also contains the binary)
- if: runner.os == 'macOS'
run: rm dist/emailproxy
# zip the built pyinstaller output, naming according to tag and OS
- uses: thedoctor0/[email protected]
with:
type: zip
directory: dist/
filename: emailproxy-${{ needs.get_tag.outputs.output }}_pyinstaller-${{ runner.os }}.zip
# append the pyinstaller zip to the latest release
- uses: xresloader/[email protected]
with:
file: dist/*.zip
update_latest_release: true
# clean up pyinstaller assets and add platform-specific nuitka configuration options (`move` alias usage as above)
- run: |
rm dist/emailproxy-${{ needs.get_tag.outputs.output }}_pyinstaller-${{ runner.os }}.zip
move emailproxy.py . 2> nul || { shopt -s expand_aliases; alias move=mv; }
move emailproxy.py _.py
echo '# nuitka-project-if: {OS} in ("Windows"):' >> _.txt
echo '# nuitka-project: --windows-icon-from-ico=icon.png' >> _.txt
echo '# nuitka-project-if: {OS} == "Darwin":' >> _.txt
echo '# nuitka-project: --macos-app-icon=icon.png' >> _.txt
move _.txt emailproxy.py
cat _.py >> emailproxy.py
# build the nuitka version - by default, this uses the options `--mode=app --assume-yes-for-downloads --output-dir=build` (see: https://github.com/Nuitka/Nuitka-Action/blob/main/action.yml)
- uses: Nuitka/Nuitka-Action@main
with:
nuitka-version: main
script-name: emailproxy.py
include-package: |
prompt_toolkit
timeago.locales.en_short
certifi
boto3
requests
google
jwt
nofollow-import-to: '*.tests'
# replace previous build files (-f vs. -fo behaviour differences mean we can't combine); add macOS quarantine tips
- if: runner.os == 'macOS'
run: |
rm -rf dist/emailproxy.app/
echo "\nIf macOS says the app is damaged, run `xattr -dr com.apple.quarantine emailproxy.app`" >> dist/GettingStarted.txt
echo 'If you still have problems, try no-GUI mode: `emailproxy.app/Contents/MacOS/emailproxy --no-gui`' >> dist/GettingStarted.txt
mv build/emailproxy.app/ dist/
- if: runner.os == 'Windows'
run: |
rm dist/emailproxy.exe
move build/emailproxy.exe dist/
# zip the built nuitka output, naming according to tag and OS
- uses: thedoctor0/[email protected]
with:
type: zip
directory: dist/
filename: emailproxy-${{ needs.get_tag.outputs.output }}_nuitka-${{ runner.os }}.zip
# append the nuitka zip to the latest release
- uses: xresloader/[email protected]
with:
file: dist/*.zip
update_latest_release: true