Skip to content

Commit

Permalink
set up github releases
Browse files Browse the repository at this point in the history
  • Loading branch information
webecke committed Oct 25, 2024
1 parent 03e32d8 commit 5c38ba0
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 58 deletions.
50 changes: 30 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,35 @@ name: Build Executables
on:
push:
tags:
- 'v*' # Trigger on version tags
- 'v*'

jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ['3.10']
include:
- os: windows-latest
artifact_name: wilford-windows
- os: ubuntu-latest
artifact_name: wilford-linux
- os: macos-latest
artifact_name: wilford-macos

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
shell: bash

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -29,31 +43,27 @@ jobs:
- name: Build with PyInstaller
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
pyinstaller --onefile --name wilford-windows main.py
elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
pyinstaller --onefile --name wilford-linux main.py
else
pyinstaller --onefile --name wilford-macos main.py
fi
pyinstaller --onefile --name "${{ matrix.artifact_name }}" main.py
shell: bash

- name: Set Unix Permissions
if: matrix.os != 'windows-latest'
run: |
chmod +x "dist/${{ matrix.artifact_name }}"
ls -l "dist/${{ matrix.artifact_name }}"
shell: bash

- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: wilford-${{ matrix.os }}
path: |
dist/wilford-windows.exe
dist/wilford-linux
dist/wilford-macos
name: ${{ matrix.artifact_name }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
path: dist/${{ matrix.artifact_name }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
permissions: 0755

- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/wilford-windows.exe
dist/wilford-linux
dist/wilford-macos
files: dist/${{ matrix.artifact_name }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
# Wilford
Named after the LDS Prophet Wilford Woodruff, this is a web scraping tool to download LDS Conference Talks

Do you like listening to LDS General Conference talks? Do you wish you had a girlfriend? Do you need a way to download General Conference talks in bulk?

**Wilford** can help you with 2 of those!

**Wilford** is a simple text-based program that lets you download General Conference Talks from the [Church of Jesus Christ of Latter-day Saints](https://churchofjesuschrist.org/study/general-conference) by speaker.

**WARNING**
This program is kind of janky when compiled. You might just have a better experience downloading the source code than trying to run it from the "executable" in the release

## Install Wilford

If you want to try out **Wilford**, then you have two options:
_Remember this is a beta program built by a random college kid. There are a million problems with this. I'm keeping track of things to do [here](https://github.com/users/DallinFromEarth/projects/4)_


[Click here](https://github.com/DallinFromEarth/Wilford/releases/latest) to download the latest release of Wilford. Download the file based on your operating system. (`wilford-macos` for Mac, etc)

### macOS
1. Download both `wilford-macos-vX.X.X` and `install-mac.sh`
2. Open Terminal in the download directory
3. Run these commands to get macOS to let you run the code:
```bash
chmod +x wilford-macos
xattr -rd com.apple.quarantine wilford-macos
```
4. When running for the first time, you'll need to:
- Right-click the executable
- Select 'Open'
- Click 'Open' in the security dialog

### Windows
Simply download and double-click `wilford-windows.exe`. Windows may show a security warning since the app isn't signed - click "More info" and then "Run anyway" to proceed.

### Linux
_I don't use Linux, so these install steps come from our AI friend Claude. Trust at your own peril._
1. Download `wilford-linux`
2. Open Terminal in the download directory
3. Make it executable:
```bash
chmod +x wilford-linux
```
4. Run it:
```bash
./wilford-linux
```

Alternatively, move it to a directory in your PATH:
```bash
sudo mv wilford-linux /usr/local/bin/wilford
wilford
```
79 changes: 47 additions & 32 deletions src/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
View it on GitHub: https://github.com/DallinFromEarth/Wilford
"""
import shutil
import sys

# ANSI escape codes
ITALIC_START = '\x1B[3m'
Expand All @@ -18,37 +19,47 @@ def set_context(context:str):


def get_input(input_prompt="", can_skip=False):
field = input(input_prompt + "\n> ")
field = field.strip()
field_lower = field.lower()

if (not can_skip) and field == "":
print("No input provided")
return get_input(input_prompt, can_skip)
elif (field_lower == "home") or (field_lower == "main"):
print("\n\n\n")
print("!!! Returning to the main menu !!!")
raise ReturnToMainMenu
elif field_lower == "restart":
restart_program()
return get_input(input_prompt, can_skip)
elif field_lower == "help":
show_help_menu()
return get_input(input_prompt, can_skip)
elif field_lower == "terms":
display_terms()
try:
field = input(input_prompt + "\n> ").strip()
field_lower = field.lower()

if (not can_skip) and field == "":
print("No input provided")
return get_input(input_prompt, can_skip)
elif (field_lower == "home") or (field_lower == "main"):
print("\n\n\n")
print("!!! Returning to the main menu !!!")
raise ReturnToMainMenu
elif field_lower == "restart":
restart_program()
return get_input(input_prompt, can_skip)
elif field_lower == "help":
show_help_menu()
return get_input(input_prompt, can_skip)
elif field_lower == "terms":
display_terms()
return get_input(input_prompt, can_skip)
elif field_lower == "quit":
close_program()
return get_input(input_prompt, can_skip)

return field
except EOFError:
print("\nError reading input. Please try again.")
return get_input(input_prompt, can_skip)
elif field_lower == "quit":
except KeyboardInterrupt:
print("\nOperation cancelled by user")
close_program()
return get_input(input_prompt, can_skip)

return field


def get_boolean_input(input_prompt):
print(input_prompt)
verification = get_input("y -> yes, anything else -> no", True)
return verification == 'y'
try:
print(input_prompt)
verification = get_input("y -> yes, anything else -> no", True)
return verification.lower().strip() == 'y'
except Exception as e:
print(f"Error getting boolean input: {e}")
return False


def show_help_menu():
Expand Down Expand Up @@ -101,12 +112,16 @@ def display_terms():


def close_program():
verification = get_boolean_input("Are you sure you want to quit?")
if verification:
print("Thank you for using Wilford")
quit()
else:
return None
try:
verification = get_boolean_input("Are you sure you want to quit?")
if verification:
print("Thank you for using Wilford")
sys.exit(0)
else:
return None
except Exception as e:
print(f"Error during program closure: {e}")
sys.exit(1)


def restart_program():
Expand Down
12 changes: 7 additions & 5 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def set(self, key: str, value: str):

def _get_config_dir(self) -> Path:
if os.name == 'nt': # Windows
base_dir = Path(os.getenv('APPDATA', ''))
base_dir = Path(os.path.expanduser('~')) / 'AppData' / 'Roaming'
else: # Unix-like
base_dir = Path.home() / '.config'
base_dir = Path(os.path.expanduser('~')) / '.config'

config_dir = base_dir / self.app_name
config_dir.mkdir(parents=True, exist_ok=True)
Expand All @@ -51,7 +51,7 @@ def _get_config_dir(self) -> Path:
def load(self) -> None:
try:
if self.config_file.exists():
with open(self.config_file, 'r') as f:
with open(self.config_file, 'r', encoding='utf-8') as f:
stored_config = json.load(f)
# Start with defaults
self.set_defaults()
Expand All @@ -69,10 +69,12 @@ def load(self) -> None:
def save(self) -> None:
"""Save current configuration to disk."""
try:
with open(self.config_file, 'w') as f:
self.config_dir.mkdir(parents=True, exist_ok=True)
with open(self.config_file, 'w', encoding='utf-8') as f:
json.dump(self._config, f, indent=2)
except IOError as e:
raise ConfigurationError(f"Error saving config: {e}")
print(f"Error saving config: {e}")
# Don't raise error, just notify user

def set_defaults(self) -> None:
"""Set default configuration values."""
Expand Down

0 comments on commit 5c38ba0

Please sign in to comment.