Skip to content

Commit df29adb

Browse files
authored
Merge branch 'SubstantialCattle5:main' into main
2 parents 43c73e1 + 74ffbc4 commit df29adb

12 files changed

Lines changed: 1183 additions & 68 deletions

File tree

.github/workflows/clone.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: GitHub Clone Count Update Everyday
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Run daily at midnight UTC
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
token: ${{ secrets.GH_PAT }}
16+
fetch-depth: 0
17+
18+
- name: gh login
19+
run: echo "${{ secrets.GH_PAT }}" | gh auth login --with-token
20+
21+
- name: parse latest clone count
22+
run: |
23+
curl --user "${{ github.actor }}:${{ secrets.GH_PAT }}" \
24+
-H "Accept: application/vnd.github.v3+json" \
25+
https://api.github.com/repos/${{ github.repository }}/traffic/clones \
26+
> clone.json
27+
28+
- name: create gist and download previous count
29+
id: set_id
30+
run: |
31+
# Check if GIST_ID secret exists and is not empty
32+
if [ -n "${{ secrets.GIST_ID }}" ]; then
33+
echo "GIST_ID found: ${{ secrets.GIST_ID }}"
34+
echo "GIST=${{ secrets.GIST_ID }}" >> $GITHUB_OUTPUT
35+
curl -f https://gist.githubusercontent.com/${{ github.actor }}/${{ secrets.GIST_ID }}/raw/clone.json > clone_before.json 2>/dev/null || cp clone.json clone_before.json
36+
if cat clone_before.json | grep '404: Not Found' 2>/dev/null; then
37+
echo "GIST_ID not valid anymore. Creating another gist..."
38+
gist_id=$(gh gist create clone.json | awk -F / '{print $NF}')
39+
echo "New GIST_ID: $gist_id"
40+
echo $gist_id | gh secret set GIST_ID
41+
echo "GIST=$gist_id" >> $GITHUB_OUTPUT
42+
cp clone.json clone_before.json
43+
git rm --ignore-unmatch CLONE.md
44+
fi
45+
else
46+
echo "GIST_ID not found. Creating a gist..."
47+
gist_id=$(gh gist create clone.json | awk -F / '{print $NF}')
48+
echo "Created GIST_ID: $gist_id"
49+
echo $gist_id | gh secret set GIST_ID
50+
echo "GIST=$gist_id" >> $GITHUB_OUTPUT
51+
cp clone.json clone_before.json
52+
fi
53+
54+
# Ensure clone_before.json has valid content for the Python script
55+
if [ ! -s clone_before.json ] || ! jq empty clone_before.json 2>/dev/null; then
56+
echo "clone_before.json is empty or invalid, using current clone.json"
57+
cp clone.json clone_before.json
58+
fi
59+
60+
- name: update clone.json
61+
run: |
62+
curl https://raw.githubusercontent.com/MShawon/github-clone-count-badge/master/main.py > main.py
63+
python3 main.py
64+
65+
- name: Update gist with latest count
66+
run: |
67+
content=$(sed -e 's/\\/\\\\/g' -e 's/\t/\\t/g' -e 's/\"/\\"/g' -e 's/\r//g' "clone.json" | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
68+
echo '{"description": "${{ github.repository }} clone statistics", "files": {"clone.json": {"content": "'"$content"'"}}}' > post_clone.json
69+
curl -s -X PATCH \
70+
--user "${{ github.actor }}:${{ secrets.GH_PAT }}" \
71+
-H "Content-Type: application/json" \
72+
-d @post_clone.json https://api.github.com/gists/${{ steps.set_id.outputs.GIST }} > /dev/null 2>&1
73+
74+
- name: Update README with clone badge
75+
run: |
76+
GIST_ID="${{ steps.set_id.outputs.GIST }}"
77+
78+
echo "GIST_ID: $GIST_ID"
79+
80+
# Only update if we have a valid GIST_ID
81+
if [ -n "$GIST_ID" ]; then
82+
shields="https://img.shields.io/badge/dynamic/json?color=success&label=Clone&query=count&url="
83+
url="https://gist.githubusercontent.com/${{ github.actor }}/${GIST_ID}/raw/clone.json"
84+
repo="https://github.com/${{ github.repository }}"
85+
badge="[![GitHub Clones](${shields}${url}&logo=github)](${repo})"
86+
87+
echo "Generated badge: $badge"
88+
89+
# Check if badge already exists in README
90+
if ! grep -q "GitHub Clones" README.md; then
91+
echo "Badge not found in README, adding it..."
92+
# Escape special characters for sed (especially & which means "matched pattern")
93+
escaped_badge=$(echo "$badge" | sed 's/[&/\]/\\&/g')
94+
# Replace the comment placeholder with the actual badge
95+
sed -i 's|<!-- Clone badge will be auto-generated after first workflow run -->|'"$escaped_badge"'|g' README.md
96+
97+
echo "README after replacement:"
98+
head -n 10 README.md
99+
100+
git config --global user.name "GitHub Action"
101+
git config --global user.email "action@github.com"
102+
git add README.md
103+
104+
if git diff --staged --quiet; then
105+
echo "No changes to commit"
106+
else
107+
echo "Committing changes..."
108+
git commit -m "Add clone count badge to README"
109+
git push origin main
110+
echo "Changes pushed successfully"
111+
fi
112+
else
113+
echo "Badge already exists in README, skipping update"
114+
fi
115+
else
116+
echo "No GIST_ID found, skipping README update"
117+
fi
118+

README.md

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
[![Release](https://github.com/substantialcattle5/sietch/actions/workflows/release.yml/badge.svg)](https://github.com/substantialcattle5/sietch/actions/workflows/release.yml)
55
[![codecov](https://codecov.io/gh/substantialcattle5/sietch/branch/main/graph/badge.svg)](https://codecov.io/gh/substantialcattle5/sietch)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/substantialcattle5/sietch)](https://goreportcard.com/report/github.com/substantialcattle5/sietch)
7+
[![GitHub Clones](https://img.shields.io/badge/dynamic/json?color=success&label=Clone&query=count&url=https://gist.githubusercontent.com/SubstantialCattle5/a8c741d7828edd5af9f6128e583ff9a7/raw/clone.json&logo=github)](https://github.com/SubstantialCattle5/Sietch)
78

89
Sietch creates self-contained encrypted vaults that can sync over LAN, sneakernet (USB drives), or weak WiFi networks. It operates fully offline, using chunked data, encryption, and peer-to-peer protocols to ensure your files are always protected and available—even when the internet is not.
910

1011
## Why Sietch?
1112

1213
Sietch Vault is designed for environments where:
1314

14-
* Internet is scarce, censored, or unreliable
15-
* Data privacy is a necessity, not an optional feature
16-
* People work nomadically—researchers, journalists, activists
15+
- Internet is scarce, censored, or unreliable
16+
- Data privacy is a necessity, not an optional feature
17+
- People work nomadically—researchers, journalists, activists
1718

1819
## Quick Start
1920

@@ -28,12 +29,14 @@ make build
2829
### Basic Usage
2930

3031
**Create a vault**
32+
3133
```bash
3234
sietch init --name dune --key-type aes # AES-256-GCM encryption
3335
sietch init --name dune --key-type chacha20 # ChaCha20-Poly1305 encryption
3436
```
3537

3638
**Add files**
39+
3740
```bash
3841
# Single file
3942
sietch add ./secrets/thumper-plans.pdf documents/
@@ -46,13 +49,15 @@ sietch add ~/photos/img1.jpg ~/photos/img2.jpg vault/photos/
4649
```
4750

4851
**Sync over LAN**
52+
4953
```bash
5054
sietch sync /ip4/192.168.1.42/tcp/4001/p2p/QmPeerID
5155
# or auto-discover peers
5256
sietch sync
5357
```
5458

5559
**Retrieve files**
60+
5661
```bash
5762
sietch get thumper-plans.pdf ./retrieved/
5863
```
@@ -70,30 +75,38 @@ sietch get thumper-plans.pdf ./retrieved/
7075
## How It Works
7176

7277
### Chunking & Deduplication
73-
* Files are split into configurable chunks (default: 4MB)
74-
* Identical chunks across files are deduplicated to save space
75-
* Please Refer [this](internal/deduplication/README.md) documentation to understand how Deduplication works.
78+
79+
- Files are split into configurable chunks (default: 4MB)
80+
- Identical chunks across files are deduplicated to save space
81+
- Please Refer [this](internal/deduplication/README.md) documentation to understand how Deduplication works.
7682

7783
### Encryption
84+
7885
Each chunk is encrypted before storage using:
79-
* **Symmetric**: AES-256-GCM or ChaCha20-Poly1305 with passphrase
80-
* **Asymmetric**: GPG-compatible public/private keypairs
86+
87+
- **Symmetric**: AES-256-GCM or ChaCha20-Poly1305 with passphrase
88+
- **Asymmetric**: GPG-compatible public/private keypairs
8189

8290
### Peer Discovery
91+
8392
Peers discover each other via:
84-
* LAN gossip (UDP broadcast)
85-
* Manual IP whitelisting
86-
* QR-code sharing *(coming soon)*
93+
94+
- LAN gossip (UDP broadcast)
95+
- Manual IP whitelisting
96+
- QR-code sharing _(coming soon)_
8797

8898
### Syncing
99+
89100
Inspired by rsync, Sietch only transfers:
90-
* Missing chunks
91-
* Changed metadata
92-
* Over encrypted TCP connections with optional compression
101+
102+
- Missing chunks
103+
- Changed metadata
104+
- Over encrypted TCP connections with optional compression
93105

94106
## Available Commands
95107

96108
### Core Operations
109+
97110
```bash
98111
sietch init [flags] # Initialize a new vault
99112
sietch add <source> <destination> [args...] # Add files to vault (multiple file support)
@@ -103,13 +116,15 @@ sietch delete <filename> # Delete files from vault
103116
```
104117

105118
### Network Operations
119+
106120
```bash
107121
sietch discover [flags] # Discover peers on local network
108122
sietch sync [peer-address] # Sync with other vaults
109123
sietch sneak [flags] # Transfer via sneakernet (USB)
110124
```
111125

112126
### Management
127+
113128
```bash
114129
sietch dedup stats # Show deduplication statistics
115130
sietch dedup gc # Run garbage collection
@@ -120,27 +135,31 @@ sietch scaffold [flags] # Create vault from template
120135
## Advanced Usage
121136

122137
**View vault contents**
138+
123139
```bash
124140
sietch ls # List all files
125141
sietch ls docs/ # List files in specific directory
126142
sietch ls --long # Show detailed information
127143
```
128144

129145
**Network synchronization**
146+
130147
```bash
131148
sietch discover # Find peers automatically
132149
sietch sync # Auto-discover and sync
133150
sietch sync /ip4/192.168.1.5/tcp/4001/p2p/QmPeerID # Sync with specific peer
134151
```
135152

136153
**Sneakernet transfer**
154+
137155
```bash
138156
sietch sneak # Interactive mode
139157
sietch sneak --source /media/usb/vault # Transfer from USB vault
140158
sietch sneak --dry-run --source /backup/vault # Preview transfer
141159
```
142160

143161
**Deduplication management**
162+
144163
```bash
145164
sietch dedup stats # Show statistics
146165
sietch dedup gc # Clean unreferenced chunks
@@ -168,26 +187,29 @@ sietch manifest
168187
## Development
169188

170189
### Prerequisites
171-
* **Go 1.23+**[Download](https://golang.org/dl/)
172-
* **Git** – Version control
190+
191+
- **Go 1.23+**[Download](https://golang.org/dl/)
192+
- **Git** – Version control
173193

174194
### Quick Development Setup
175195

176196
1. **Clone and setup**
177-
```bash
178-
git clone https://github.com/substantialcattle5/sietch.git
179-
cd sietch
180-
./scripts/setup-hooks.sh
181-
```
197+
198+
```bash
199+
git clone https://github.com/substantialcattle5/sietch.git
200+
cd sietch
201+
./scripts/setup-hooks.sh
202+
```
182203

183204
2. **Verify installation**
184-
```bash
185-
make check-versions
186-
make build
187-
make test
188-
```
205+
```bash
206+
make check-versions
207+
make build
208+
make test
209+
```
189210

190211
### Available Commands
212+
191213
```bash
192214
make help # List all commands
193215
make dev # Format, test, build
@@ -203,13 +225,15 @@ For detailed development guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
203225
We welcome contributions of all kinds! Whether you're fixing bugs, adding features, improving documentation, or enhancing UX.
204226

205227
**Quick contribution steps:**
228+
206229
1. Fork the repository
207230
2. Create a feature branch: `git checkout -b feature/stillsuit`
208231
3. Make your changes following our [style guidelines](CONTRIBUTING.md#styleguides)
209232
4. Commit using [conventional commits](CONTRIBUTING.md#commit-messages)
210233
5. Push and open a Pull Request
211234

212235
See our [Contributing Guide](CONTRIBUTING.md) for detailed information about:
236+
213237
- Development environment setup
214238
- Code style guidelines
215239
- Testing requirements
@@ -218,9 +242,10 @@ See our [Contributing Guide](CONTRIBUTING.md) for detailed information about:
218242
## Inspiration & Credits
219243

220244
Sietch draws inspiration from:
221-
* **Syncthing** - Decentralized file synchronization
222-
* **IPFS** - Content-addressed storage
223-
* **Obsidian Sync** - Seamless cross-device syncing
245+
246+
- **Syncthing** - Decentralized file synchronization
247+
- **IPFS** - Content-addressed storage
248+
- **Obsidian Sync** - Seamless cross-device syncing
224249

225250
Built with ❤️ in Go by the open source community.
226251

@@ -267,6 +292,13 @@ Thanks to all our amazing contributors!
267292
<sub><b>Abhinav Garg</b></sub>
268293
</a>
269294
</td>
295+
<td align="center">
296+
<a href="https://github.com/Janmesh23">
297+
<img src="https://avatars.githubusercontent.com/u/183159485?v=4" width="100;" alt="Janmesh23"/>
298+
<br />
299+
<sub><b>Janmesh </b></sub>
300+
</a>
301+
</td>
270302
<td align="center">
271303
<a href="https://github.com/Akash29g">
272304
<img src="https://avatars.githubusercontent.com/u/77738997?v=4" width="100;" alt="Akash29g"/>
@@ -308,4 +340,4 @@ Licensed under the **MIT License** – see the [LICENSE](LICENSE) file for detai
308340

309341
---
310342

311-
> *"When you live in the desert, you develop a very strong survival instinct."* – Chani, *Dune*
343+
> _"When you live in the desert, you develop a very strong survival instinct."_ – Chani, _Dune_

0 commit comments

Comments
 (0)