Skip to content

Commit 6f25f02

Browse files
authored
Rewrite in Zig (#144)
2 parents 631c67a + 31acb88 commit 6f25f02

20 files changed

Lines changed: 2077 additions & 1322 deletions

.github/workflows/main.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,54 @@ name: Generate Stats Images
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches:
6+
- master
67
schedule:
78
- cron: "5 0 * * *"
89
workflow_dispatch:
910

1011
permissions:
1112
contents: write
1213

14+
defaults:
15+
run:
16+
shell: bash -euxo pipefail {0}
17+
1318
jobs:
1419
build:
1520
runs-on: ubuntu-latest
16-
1721
steps:
18-
# Check out repository under $GITHUB_WORKSPACE, so the job can access it
19-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v6
23+
- name: Checkout history branch
24+
run: |
25+
git config --global user.name "jstrieb/github-stats"
26+
git config --global user.email "github-stats[bot]@jstrieb.github.io"
27+
# Push generated files to the generated branch
28+
git pull
29+
git checkout generated || git checkout -b generated
30+
git merge master || true
2031
21-
# Run using Python 3.8 for consistency and aiohttp
22-
- name: Set up Python 3.8
23-
uses: actions/setup-python@v4
32+
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2 tag
2433
with:
25-
python-version: '3.8'
26-
architecture: 'x64'
27-
cache: 'pip'
34+
version: 0.15.2
2835

29-
# Install dependencies with `pip`
30-
- name: Install requirements
36+
- name: Build
3137
run: |
32-
python3 -m pip install --upgrade pip setuptools wheel
33-
python3 -m pip install -r requirements.txt
38+
zig build --release
3439
35-
# Generate all statistics images
3640
- name: Generate images
3741
run: |
38-
python3 --version
39-
python3 generate_images.py
42+
./zig-out/bin/github-stats
4043
env:
4144
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
EXCLUDED: ${{ secrets.EXCLUDED }}
44-
EXCLUDED_LANGS: ${{ secrets.EXCLUDED_LANGS }}
45-
EXCLUDE_FORKED_REPOS: true
45+
EXCLUDE_REPOS: ${{ secrets.EXCLUDE_REPOS }}
46+
EXCLUDE_LANGS: ${{ secrets.EXCLUDE_LANGS }}
47+
EXCLUDE_PRIVATE: "false"
48+
DEBUG: "false"
4649

47-
# Commit all changed files to the repository
4850
- name: Commit to the repo
4951
run: |
50-
git config --global user.name "jstrieb/github-stats"
51-
git config --global user.email "github-stats[bot]@jstrieb.github.io"
5252
git add .
5353
# Force the build to succeed, even if no files were changed
5454
git commit -m 'Update generated files' || true
55-
git push
55+
git push --set-upstream origin generated

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build Release Binaries
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
defaults:
10+
run:
11+
shell: bash -euxo pipefail {0}
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2 tag
20+
with:
21+
version: 0.15.2
22+
23+
- name: Build
24+
run: |
25+
zig build release
26+
27+
- name: Upload Release Artifacts
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
30+
TAG: ${{ github.ref_name }}
31+
run: |
32+
(
33+
cd zig-out/bin/
34+
gh release create \
35+
"${TAG}" \
36+
--title "${TAG} Release" \
37+
*
38+
)

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,7 @@ dmypy.json
134134

135135
# PyCharm project files
136136
.idea
137+
138+
# Zig files
139+
.zig-cache
140+
zig-out

0 commit comments

Comments
 (0)