Skip to content

Commit 7313751

Browse files
committed
v1
1 parent 85fa16f commit 7313751

File tree

10 files changed

+841
-21
lines changed

10 files changed

+841
-21
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: goto-bus-stop/setup-zig@v2
14+
with:
15+
version: 0.15.1
16+
- run: zig build test
17+

.github/workflows/release.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Version to release (e.g. 0.1.0). Creates tag vX.Y.Z if needed."
11+
required: true
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build-tarballs:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- runner: ubuntu-latest
23+
target: x86_64-linux-musl
24+
dist_os: linux
25+
dist_arch: amd64
26+
- runner: ubuntu-latest
27+
target: aarch64-linux-musl
28+
dist_os: linux
29+
dist_arch: arm64
30+
- runner: macos-latest
31+
target: x86_64-macos
32+
dist_os: darwin
33+
dist_arch: amd64
34+
- runner: macos-latest
35+
target: aarch64-macos
36+
dist_os: darwin
37+
dist_arch: arm64
38+
39+
runs-on: ${{ matrix.runner }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
- uses: goto-bus-stop/setup-zig@v2
43+
with:
44+
version: 0.15.1
45+
46+
- name: Resolve version
47+
id: meta
48+
shell: bash
49+
run: |
50+
set -euo pipefail
51+
raw="${{ github.event.inputs.version || github.ref_name }}"
52+
if [[ "$raw" != v* ]]; then tag="v$raw"; else tag="$raw"; fi
53+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
54+
echo "version=${tag#v}" >> "$GITHUB_OUTPUT"
55+
56+
- name: Build tarball
57+
shell: bash
58+
run: |
59+
set -euo pipefail
60+
version="${{ steps.meta.outputs.version }}"
61+
zig build -Doptimize=ReleaseSafe -Dtarget=${{ matrix.target }} -Dversion="${version}"
62+
63+
mkdir -p dist
64+
cp zig-out/bin/nytgames dist/nytgames
65+
cp LICENSE dist/LICENSE
66+
cp README.md dist/README.md
67+
68+
tarball="nytgames-cli_${version}_${{ matrix.dist_os }}_${{ matrix.dist_arch }}.tar.gz"
69+
tar -C dist -czf "${tarball}" nytgames LICENSE README.md
70+
echo "built ${tarball}"
71+
72+
- uses: actions/upload-artifact@v4
73+
with:
74+
name: tarballs-${{ matrix.dist_os }}-${{ matrix.dist_arch }}
75+
path: nytgames-cli_*.tar.gz
76+
if-no-files-found: error
77+
78+
publish:
79+
needs: build-tarballs
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- uses: actions/download-artifact@v4
85+
with:
86+
path: dist
87+
pattern: tarballs-*
88+
merge-multiple: true
89+
90+
- name: Resolve version
91+
id: meta
92+
shell: bash
93+
run: |
94+
set -euo pipefail
95+
raw="${{ github.event.inputs.version || github.ref_name }}"
96+
if [[ "$raw" != v* ]]; then tag="v$raw"; else tag="$raw"; fi
97+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
98+
echo "version=${tag#v}" >> "$GITHUB_OUTPUT"
99+
100+
- name: Build Linux packages + Homebrew formula
101+
shell: bash
102+
run: |
103+
set -euo pipefail
104+
version="${{ steps.meta.outputs.version }}"
105+
106+
ls -la dist
107+
108+
# Initial checksums (tarballs only) used for generating the brew formula.
109+
(cd dist && sha256sum nytgames-cli_*.tar.gz > checksums.txt)
110+
111+
./scripts/generate-homebrew-formula.sh --version "${version}" --checksums dist/checksums.txt --out dist/nytgames-cli.rb
112+
113+
sudo apt-get update -y
114+
sudo apt-get install -y rpm
115+
116+
mkdir -p dist/_linux_amd64 dist/_linux_arm64
117+
118+
tar -xzf "dist/nytgames-cli_${version}_linux_amd64.tar.gz" -C dist/_linux_amd64
119+
tar -xzf "dist/nytgames-cli_${version}_linux_arm64.tar.gz" -C dist/_linux_arm64
120+
121+
./scripts/build-deb.sh --version "${version}" --arch amd64 --bin dist/_linux_amd64/nytgames --out "dist/nytgames-cli_${version}_linux_amd64.deb"
122+
./scripts/build-deb.sh --version "${version}" --arch arm64 --bin dist/_linux_arm64/nytgames --out "dist/nytgames-cli_${version}_linux_arm64.deb"
123+
124+
./scripts/build-rpm.sh --version "${version}" --arch amd64 --tar "dist/nytgames-cli_${version}_linux_amd64.tar.gz" --out "dist/nytgames-cli_${version}_linux_amd64.rpm"
125+
./scripts/build-rpm.sh --version "${version}" --arch arm64 --tar "dist/nytgames-cli_${version}_linux_arm64.tar.gz" --out "dist/nytgames-cli_${version}_linux_arm64.rpm"
126+
127+
# Final checksums include all artifacts (excluding checksums.txt itself).
128+
(cd dist && sha256sum nytgames-cli_*.tar.gz nytgames-cli_*.deb nytgames-cli_*.rpm nytgames-cli.rb > checksums.txt)
129+
130+
- name: Upload release assets
131+
uses: softprops/action-gh-release@v2
132+
with:
133+
tag_name: ${{ steps.meta.outputs.tag }}
134+
target_commitish: ${{ github.sha }}
135+
generate_release_notes: true
136+
files: |
137+
dist/nytgames-cli_*.tar.gz
138+
dist/nytgames-cli_*.deb
139+
dist/nytgames-cli_*.rpm
140+
dist/nytgames-cli.rb
141+
dist/checksums.txt

README.md

Lines changed: 126 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,132 @@
1-
# New York Times Game cli
1+
# nytgames-cli
22

3-
A CLI tool to play NYT Games in your terminal.
3+
[![CI](https://github.com/ph8n/nytgames-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/ph8n/nytgames-cli/actions/workflows/ci.yml)
44

5-
## Build
5+
Play NYT Games in your terminal, with local stats tracking.
66

7-
- `zig build`
8-
- Run: `zig build run` (or `./zig-out/bin/nytgames`)
7+
**Games**
8+
- Wordle (daily)
9+
- Wordle Unlimited (offline)
10+
- Connections (daily)
11+
12+
Not affiliated with The New York Times.
13+
14+
## Install
15+
16+
### Homebrew (macOS + Linux)
17+
18+
This project publishes a self-contained Homebrew formula as a release asset.
19+
20+
```bash
21+
brew install --formula https://github.com/ph8n/nytgames-cli/releases/download/vX.Y.Z/nytgames-cli.rb
22+
```
23+
24+
### Curl (macOS + Linux)
25+
26+
Installs the prebuilt binary from GitHub Releases.
27+
28+
```bash
29+
curl -fsSL https://raw.githubusercontent.com/ph8n/nytgames-cli/main/scripts/install.sh | bash
30+
```
31+
32+
Options:
33+
- Pin a version:
34+
- `curl -fsSL https://raw.githubusercontent.com/ph8n/nytgames-cli/main/scripts/install.sh | NYTGAMES_CLI_VERSION=X.Y.Z bash`
35+
- Choose install dir: `NYTGAMES_CLI_INSTALL_DIR=~/.local/bin`
36+
37+
### Linux packages
38+
39+
Download the package from the GitHub Release page:
40+
- Debian/Ubuntu (`.deb`): `sudo apt install ./nytgames-cli_X.Y.Z_linux_amd64.deb`
41+
- Fedora/RHEL (`.rpm`): `sudo dnf install ./nytgames-cli_X.Y.Z_linux_amd64.rpm`
42+
43+
Arch:
44+
- AUR template: `packaging/aur/nytgames-cli-bin/PKGBUILD`
945

1046
## Usage
1147

12-
- Menu: `nytgames`
13-
- Wordle (daily): `nytgames wordle`
14-
- Wordle Unlimited: `nytgames unlimited` (or `nytgames wordle unlimited`)
15-
- Connections: `nytgames connections`
48+
```bash
49+
nytgames --help
50+
nytgames --version
51+
```
52+
53+
Run the menu:
54+
```bash
55+
nytgames
56+
```
57+
58+
Direct launch:
59+
```bash
60+
nytgames wordle
61+
nytgames unlimited # (or: nytgames wordle unlimited)
62+
nytgames connections
63+
```
64+
65+
Dev mode (bypasses the “already played today” screen):
66+
```bash
67+
nytgames --dev
68+
```
69+
70+
## Controls
71+
72+
Menu:
73+
- Left/Right or `h/l`: change game
74+
- Up/Down or `j/k`: choose Play vs Stats
75+
- Enter/Space: confirm
76+
- Ctrl+C: quit
77+
78+
Stats:
79+
- Left/Right or `h/l`: change month
80+
- `q`/Esc: back
81+
- Ctrl+C: quit
82+
83+
Wordle:
84+
- Type letters, Backspace, Enter to submit
85+
- `q`/Esc: menu
86+
- Ctrl+C: quit
87+
88+
Connections:
89+
- Arrow keys or `h/j/k/l`: move focus
90+
- Space: select
91+
- Enter: submit
92+
- `s`: shuffle
93+
- `d`: deselect all
94+
- `q`/Esc: menu
95+
- Ctrl+C: quit
96+
97+
## Stats & data
98+
99+
- Stats are stored locally in a SQLite DB: `<app data dir>/nytg-cli/stats.db`.
100+
- Typical locations:
101+
- macOS: `~/Library/Application Support/nytg-cli/stats.db`
102+
- Linux: `${XDG_DATA_HOME:-~/.local/share}/nytg-cli/stats.db`
103+
- To reset stats: delete `stats.db`.
104+
- No telemetry; the only network requests are to fetch daily puzzles:
105+
- `https://www.nytimes.com/svc/wordle/v2/YYYY-MM-DD.json`
106+
- `https://www.nytimes.com/svc/connections/v2/YYYY-MM-DD.json`
107+
108+
Tip: your terminal needs a Unicode-capable font (the UI uses box-drawing chars and ``).
109+
110+
## Build from source
111+
112+
Requires Zig `0.15.1`.
113+
114+
```bash
115+
zig build
116+
zig build test
117+
zig build run
118+
```
119+
120+
Build with a version string (used by `nytgames --version`):
121+
```bash
122+
zig build -Dversion=0.1.0
123+
```
124+
125+
## Uninstall
126+
127+
- Remove the binary (wherever you installed it, e.g. `~/.local/bin/nytgames` or `/usr/local/bin/nytgames`).
128+
- Optional: remove your local stats DB (`nytg-cli/stats.db`).
129+
130+
## License
131+
132+
MIT — see `LICENSE`.

build.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const std = @import("std");
33
pub fn build(b: *std.Build) void {
44
const target = b.standardTargetOptions(.{});
55
const optimize = b.standardOptimizeOption(.{});
6+
const version = b.option([]const u8, "version", "Application version") orelse "0.0.0";
67

78
// Create executable module (for ZLS support)
89
const exe_mod = b.createModule(.{
@@ -11,6 +12,10 @@ pub fn build(b: *std.Build) void {
1112
.optimize = optimize,
1213
});
1314

15+
const build_options = b.addOptions();
16+
build_options.addOption([]const u8, "version", version);
17+
exe_mod.addOptions("build_options", build_options);
18+
1419
// Add vaxis dependency to module
1520
const vaxis = b.dependency("vaxis", .{
1621
.target = target,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Maintainer: ph8n
2+
3+
pkgname=nytgames-cli-bin
4+
pkgver=0.0.0
5+
pkgrel=1
6+
pkgdesc="CLI tool to play NYT Games in your terminal"
7+
arch=('x86_64' 'aarch64')
8+
url="https://github.com/ph8n/nytgames-cli"
9+
license=('MIT')
10+
provides=('nytgames-cli')
11+
conflicts=('nytgames-cli')
12+
13+
_pkgver="${pkgver}"
14+
source_x86_64=("${url}/releases/download/v${_pkgver}/nytgames-cli_${_pkgver}_linux_amd64.tar.gz")
15+
source_aarch64=("${url}/releases/download/v${_pkgver}/nytgames-cli_${_pkgver}_linux_arm64.tar.gz")
16+
17+
sha256sums_x86_64=('SKIP')
18+
sha256sums_aarch64=('SKIP')
19+
20+
package() {
21+
install -Dm755 "nytgames" "${pkgdir}/usr/bin/nytgames"
22+
install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
23+
}
24+

0 commit comments

Comments
 (0)