From 174ef7a8d443b993123585baf755278ac950e651 Mon Sep 17 00:00:00 2001 From: StevenBtw Date: Sun, 1 Nov 2026 20:12:09 +0100 Subject: [PATCH 1/5] Add a GitHub Action - downloads its own release, checks the sha256 - collects and renders; inputs for style, legend, config - CI runs it once the version is released --- .github/workflows/ci.yml | 41 +++++++++++++++++ action.yml | 99 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cad0904..4b6b473 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,6 +112,47 @@ jobs: name: gallery path: gallery/ + # The GitHub Action end to end: download the release, collect, render. + # It needs the release for Cargo.toml's version, so it waits for the tag. + action: + name: Action (${{ matrix.os }}) + needs: check + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v7 + + - name: Is this version released? + id: released + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2) + if gh release view "v$version" > /dev/null 2>&1; then + echo "yes=true" >> "$GITHUB_OUTPUT" + else + echo "::notice::v$version is not released yet; the action is checked once it is" + fi + + - uses: ./ + id: bonsai + if: steps.released.outputs.yes == 'true' + with: + output-dir: out + legend: right + + - name: Check the outputs + if: steps.released.outputs.yes == 'true' + shell: bash + run: | + for f in "${{ steps.bonsai.outputs.light }}" "${{ steps.bonsai.outputs.dark }}"; do + test -s "$f" && grep -q '&2 + exit 1 + ;; + esac + archive="gitbonsai-$target.tar.gz" + install_dir="$RUNNER_TEMP/gitbonsai" + mkdir -p "$install_dir" + if ! gh release download "v$version" --repo "$repository" --dir "$install_dir" \ + --pattern "$archive" --pattern "$archive.sha256" --clobber; then + echo "release v$version has no asset $archive; reference the action at a release tag" >&2 + exit 1 + fi + cd "$install_dir" + if command -v sha256sum > /dev/null; then + sha256sum -c "$archive.sha256" + else + shasum -a 256 -c "$archive.sha256" + fi + tar -xzf "$archive" + echo "$install_dir" >> "$GITHUB_PATH" + - name: Collect the account's activity + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + BONSAI_LOGIN: ${{ inputs.login }} + run: gitbonsai collect "$BONSAI_LOGIN" --output "$RUNNER_TEMP/bonsai.snapshot.json" + - name: Grow the bonsai + id: render + shell: bash + env: + BONSAI_OUTPUT_DIR: ${{ inputs.output-dir }} + BONSAI_STYLE: ${{ inputs.style }} + BONSAI_LEGEND: ${{ inputs.legend }} + BONSAI_CONFIG: ${{ inputs.config }} + run: | + args=(--output-dir "$BONSAI_OUTPUT_DIR" --legend "$BONSAI_LEGEND" --config "$BONSAI_CONFIG") + if [ -n "$BONSAI_STYLE" ]; then + args+=(--style "$BONSAI_STYLE") + fi + gitbonsai render "$RUNNER_TEMP/bonsai.snapshot.json" "${args[@]}" + echo "light=$BONSAI_OUTPUT_DIR/bonsai-light.svg" >> "$GITHUB_OUTPUT" + echo "dark=$BONSAI_OUTPUT_DIR/bonsai-dark.svg" >> "$GITHUB_OUTPUT" From 9612722314ab771bc8de4b8df2cd660068e5f4f3 Mon Sep 17 00:00:00 2001 From: StevenBtw Date: Sun, 1 Nov 2026 20:15:20 +0100 Subject: [PATCH 2/5] Use the action in the README - profile setup first, local CLI after - legend on the left in the hero image --- CHANGELOG.md | 6 ++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 31 +++++++++++++++++++++---------- assets/veteran-legend-dark.svg | 2 +- assets/veteran-legend-light.svg | 2 +- examples/profile-workflow.yml | 25 +++++-------------------- 7 files changed, 36 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ec9058..74b6fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to gitbonsai are recorded here. Any change to how a tree grows or looks is at least a minor version, because people will notice their tree changing. +## 0.1.2 + +- A GitHub Action: `uses: StevenBtw/gitbonsai@v0.1.2` downloads the release, + checks its sha256, then collects and renders, with inputs for style, legend + and config. The profile workflow example uses it. + ## 0.1.1 Trees change look in this release: smoother wood and softer leaves. diff --git a/Cargo.lock b/Cargo.lock index d7e9a85..0b39a16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -204,7 +204,7 @@ checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" [[package]] name = "gitbonsai" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 7c67f99..547c70e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitbonsai" -version = "0.1.1" +version = "0.1.2" edition = "2024" rust-version = "1.99.0" license = "MIT OR Apache-2.0" diff --git a/README.md b/README.md index 36affb0..6920019 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The tree is yours: it grows from your own GitHub activity, week by week. The tru | Newbie | Comeback | Veteran | | :---: | :---: | :---: | | A newcomer bonsai: a young tree in its first pot | A comeback bonsai: deadwood from the quiet years, new growth since | A veteran bonsai: tall, thick and full | -| a few months in | quiet for two years, then back | 16 years, busy since 2023 | +| a few months in | quiet for two years, then back | 16 years, busier the last few years |
What every part shows @@ -36,18 +36,18 @@ The tree is yours: it grows from your own GitHub activity, week by week. The tru
-## Use it +## Use it on your profile -Needs the [GitHub CLI](https://cli.github.com), logged in. +Add the action to a weekly workflow in your profile repository (`/`); [examples/profile-workflow.yml](examples/profile-workflow.yml) is a complete one to copy to `.github/workflows/bonsai.yml`: -```sh -cargo install gitbonsai -gitbonsai collect --output me.snapshot.json -gitbonsai render me.snapshot.json # bonsai/: light and dark SVG, PNG, preview.html -gitbonsai explain me.snapshot.json # every number behind the tree +```yaml +- uses: StevenBtw/gitbonsai@v0.1.2 + with: + output-dir: assets # bonsai-light.svg and bonsai-dark.svg + legend: left # optional: off (default), left or right ``` -On your profile, copy [examples/profile-workflow.yml](examples/profile-workflow.yml) to `.github/workflows/bonsai.yml` in `/`. It regrows the tree every week. Then add this to your README: +Then add this to your README: ```html

@@ -60,7 +60,18 @@ On your profile, copy [examples/profile-workflow.yml](examples/profile-workflow. On its own, `width="600"` suits a desktop column, and phones scale it down to fit. Next to other cards, use `400`. -Styles, leaf colors, the pot glaze and an optional legend (left or right of the tree) go in a `bonsai.toml`; see [examples/bonsai.toml](examples/bonsai.toml). +Styles, leaf colors, the pot glaze and the legend go in a `bonsai.toml`; see [examples/bonsai.toml](examples/bonsai.toml). The action reads it from the repository root, and its inputs `style` and `legend` override it. + +## Run it locally + +Needs the [GitHub CLI](https://cli.github.com), logged in. + +```sh +cargo install gitbonsai +gitbonsai collect --output me.snapshot.json +gitbonsai render me.snapshot.json # bonsai/: light and dark SVG, PNG, preview.html +gitbonsai explain me.snapshot.json # every number behind the tree +``` ## Credits diff --git a/assets/veteran-legend-dark.svg b/assets/veteran-legend-dark.svg index 58633b1..98c0844 100644 --- a/assets/veteran-legend-dark.svg +++ b/assets/veteran-legend-dark.svg @@ -1 +1 @@ -Bonsai for @fixture-veteranJapanese maple bonsai grown over 16 years, level 8. Leaves of Rust, TypeScript, Python. Four languages have turned to deadwood.gitbonsai 0.1.1; observed 2026-W44; moyogi; darkLeavesRustTypeScriptPythondeadwood: Go, JavaScript, +2Signs16 years, 26,301 contributionsnew growth this weeklifetime level 8669-week streaklongest streak 669 weeks +Bonsai for @fixture-veteranJapanese maple bonsai grown over 16 years, level 8. Leaves of Rust, TypeScript, Python. Four languages have turned to deadwood.gitbonsai 0.1.1; observed 2026-W44; moyogi; darkLeavesRustTypeScriptPythondeadwood: Go, JavaScript, +2Signs16 years, 26,301 contributionsnew growth this weeklifetime level 8669-week streaklongest streak 669 weeks diff --git a/assets/veteran-legend-light.svg b/assets/veteran-legend-light.svg index a0327bc..cc58972 100644 --- a/assets/veteran-legend-light.svg +++ b/assets/veteran-legend-light.svg @@ -1 +1 @@ -Bonsai for @fixture-veteranJapanese maple bonsai grown over 16 years, level 8. Leaves of Rust, TypeScript, Python. Four languages have turned to deadwood.gitbonsai 0.1.1; observed 2026-W44; moyogi; lightLeavesRustTypeScriptPythondeadwood: Go, JavaScript, +2Signs16 years, 26,301 contributionsnew growth this weeklifetime level 8669-week streaklongest streak 669 weeks +Bonsai for @fixture-veteranJapanese maple bonsai grown over 16 years, level 8. Leaves of Rust, TypeScript, Python. Four languages have turned to deadwood.gitbonsai 0.1.1; observed 2026-W44; moyogi; lightLeavesRustTypeScriptPythondeadwood: Go, JavaScript, +2Signs16 years, 26,301 contributionsnew growth this weeklifetime level 8669-week streaklongest streak 669 weeks diff --git a/examples/profile-workflow.yml b/examples/profile-workflow.yml index 0078fbf..70d7c59 100644 --- a/examples/profile-workflow.yml +++ b/examples/profile-workflow.yml @@ -1,7 +1,7 @@ # Regrows the bonsai every week. Copy to .github/workflows/bonsai.yml in your # profile repository (/). # -# - The built-in token is enough: everything `collect` reads is public. +# - The built-in token is enough: everything gitbonsai reads is public. # - It commits as github-actions[bot], never as you, so the tree doesn't water itself. # - Each SVG records the week it was grown, so every run commits a change and # GitHub never pauses the schedule. @@ -20,25 +20,10 @@ jobs: steps: - uses: actions/checkout@v7 - - name: Install gitbonsai (latest release) - env: - GH_TOKEN: ${{ github.token }} - run: | - gh release download --repo StevenBtw/gitbonsai \ - --pattern 'gitbonsai-x86_64-unknown-linux-musl.tar.gz*' --dir /tmp/gb - cd /tmp/gb - sha256sum -c gitbonsai-x86_64-unknown-linux-musl.tar.gz.sha256 - tar -xzf gitbonsai-x86_64-unknown-linux-musl.tar.gz - echo /tmp/gb >> "$GITHUB_PATH" - - - name: Grow the bonsai - env: - GH_TOKEN: ${{ github.token }} - run: | - gitbonsai collect ${{ github.repository_owner }} --output /tmp/bonsai.snapshot.json - gitbonsai render /tmp/bonsai.snapshot.json --output-dir /tmp/bonsai - mkdir -p assets - cp /tmp/bonsai/bonsai-light.svg /tmp/bonsai/bonsai-dark.svg assets/ + - uses: StevenBtw/gitbonsai@v0.1.2 + with: + output-dir: assets + # legend: left # what the colors and signs mean, beside the tree - name: Commit if it changed run: | From 3818bc1d655e9ecfc022ce45fbd622ed4b5371f1 Mon Sep 17 00:00:00 2001 From: Steven <38373784+StevenBtw@users.noreply.github.com> Date: Sun, 1 Nov 2026 20:25:27 +0100 Subject: [PATCH 3/5] Update .github/workflows/ci.yml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b6b473..a7fcfa7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,7 @@ jobs: shell: bash run: | for f in "${{ steps.bonsai.outputs.light }}" "${{ steps.bonsai.outputs.dark }}"; do - test -s "$f" && grep -q ' Date: Sun, 1 Nov 2026 20:26:53 +0100 Subject: [PATCH 4/5] Address review on the action - legend input empty by default, so bonsai.toml decides - check the action after each release, not in CI - example commits the paths the action reports --- .github/workflows/ci.yml | 41 ----------------------------------- .github/workflows/release.yml | 27 +++++++++++++++++++++++ action.yml | 12 +++++++--- examples/profile-workflow.yml | 3 ++- 4 files changed, 38 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7fcfa7..cad0904 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,47 +112,6 @@ jobs: name: gallery path: gallery/ - # The GitHub Action end to end: download the release, collect, render. - # It needs the release for Cargo.toml's version, so it waits for the tag. - action: - name: Action (${{ matrix.os }}) - needs: check - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest] - steps: - - uses: actions/checkout@v7 - - - name: Is this version released? - id: released - shell: bash - env: - GH_TOKEN: ${{ github.token }} - run: | - version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2) - if gh release view "v$version" > /dev/null 2>&1; then - echo "yes=true" >> "$GITHUB_OUTPUT" - else - echo "::notice::v$version is not released yet; the action is checked once it is" - fi - - - uses: ./ - id: bonsai - if: steps.released.outputs.yes == 'true' - with: - output-dir: out - legend: right - - - name: Check the outputs - if: steps.released.outputs.yes == 'true' - shell: bash - run: | - for f in "${{ steps.bonsai.outputs.light }}" "${{ steps.bonsai.outputs.dark }}"; do - test -s "$f" && grep -q '> "$GITHUB_OUTPUT" echo "dark=$BONSAI_OUTPUT_DIR/bonsai-dark.svg" >> "$GITHUB_OUTPUT" diff --git a/examples/profile-workflow.yml b/examples/profile-workflow.yml index 70d7c59..fd4f72c 100644 --- a/examples/profile-workflow.yml +++ b/examples/profile-workflow.yml @@ -21,6 +21,7 @@ jobs: - uses: actions/checkout@v7 - uses: StevenBtw/gitbonsai@v0.1.2 + id: bonsai with: output-dir: assets # legend: left # what the colors and signs mean, beside the tree @@ -29,6 +30,6 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add assets/bonsai-light.svg assets/bonsai-dark.svg + git add "${{ steps.bonsai.outputs.light }}" "${{ steps.bonsai.outputs.dark }}" git diff --cached --quiet || git commit -m "Grow bonsai" git push From 285f36447bf2f6c538223071cdf7818846ff5a68 Mon Sep 17 00:00:00 2001 From: StevenBtw Date: Sun, 1 Nov 2026 20:30:53 +0100 Subject: [PATCH 5/5] Read-only token for the release action check --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38fe0fd..540f4b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,6 +90,9 @@ jobs: name: Action (${{ matrix.os }}) needs: release runs-on: ${{ matrix.os }} + # It runs the downloaded binary with the token: reading is all it needs. + permissions: + contents: read strategy: fail-fast: false matrix: