Skip to content

Commit e580a7d

Browse files
author
ben
committed
first commit
0 parents  commit e580a7d

61 files changed

Lines changed: 15020 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- prod
7+
tags:
8+
- 'v*'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
include:
20+
# Linux
21+
- goos: linux
22+
goarch: amd64
23+
suffix: linux-amd64
24+
- goos: linux
25+
goarch: arm64
26+
suffix: linux-arm64
27+
# Windows
28+
- goos: windows
29+
goarch: amd64
30+
suffix: windows-amd64.exe
31+
- goos: windows
32+
goarch: arm64
33+
suffix: windows-arm64.exe
34+
# macOS
35+
- goos: darwin
36+
goarch: amd64
37+
suffix: darwin-amd64
38+
- goos: darwin
39+
goarch: arm64
40+
suffix: darwin-arm64
41+
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Go
47+
uses: actions/setup-go@v5
48+
with:
49+
go-version: '1.23'
50+
51+
- name: Build
52+
env:
53+
GOOS: ${{ matrix.goos }}
54+
GOARCH: ${{ matrix.goarch }}
55+
run: |
56+
output="xsh-${{ matrix.suffix }}"
57+
go build -ldflags="-s -w -X github.com/benoitpetit/xsh/cmd.Version=${{ github.ref_name }}" -o "$output" main.go
58+
59+
# Compress binary
60+
if [[ "${{ matrix.goos }}" == "windows" ]]; then
61+
zip "$output.zip" "$output"
62+
echo "ASSET=$output.zip" >> $GITHUB_ENV
63+
else
64+
tar czf "$output.tar.gz" "$output"
65+
echo "ASSET=$output.tar.gz" >> $GITHUB_ENV
66+
fi
67+
68+
- name: Upload Artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: xsh-${{ matrix.suffix }}
72+
path: ${{ env.ASSET }}
73+
74+
release:
75+
needs: build
76+
runs-on: ubuntu-latest
77+
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/prod'
78+
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v4
82+
83+
- name: Download Artifacts
84+
uses: actions/download-artifact@v4
85+
with:
86+
path: ./artifacts
87+
pattern: xsh-*
88+
89+
- name: Create Release
90+
uses: softprops/action-gh-release@v2
91+
if: startsWith(github.ref, 'refs/tags/')
92+
with:
93+
files: ./artifacts/**/*
94+
draft: false
95+
prerelease: false
96+
generate_release_notes: true
97+
name: "Release ${{ github.ref_name }}"
98+
99+
- name: Upload to Prod Release
100+
uses: softprops/action-gh-release@v2
101+
if: github.ref == 'refs/heads/prod'
102+
with:
103+
files: ./artifacts/**/*
104+
draft: false
105+
prerelease: true
106+
tag_name: prod-latest
107+
name: "Production Build (Latest)"
108+
body: |
109+
This is the latest production build from the `prod` branch.
110+
111+
## Binaries
112+
- `xsh-linux-amd64` - Linux x86_64
113+
- `xsh-linux-arm64` - Linux ARM64
114+
- `xsh-windows-amd64.exe` - Windows x86_64
115+
- `xsh-windows-arm64.exe` - Windows ARM64
116+
- `xsh-darwin-amd64` - macOS Intel
117+
- `xsh-darwin-arm64` - macOS Apple Silicon (M1/M2/M3)
118+
119+
- name: Summary
120+
run: |
121+
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
122+
echo "" >> $GITHUB_STEP_SUMMARY
123+
echo "✅ Built for 6 platforms:" >> $GITHUB_STEP_SUMMARY
124+
echo "- Linux (amd64, arm64)" >> $GITHUB_STEP_SUMMARY
125+
echo "- Windows (amd64, arm64)" >> $GITHUB_STEP_SUMMARY
126+
echo "- macOS (amd64, arm64)" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Binaries
2+
/xsh
3+
/xsh.exe
4+
*.exe
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Build artifacts
10+
/dist/
11+
/build/
12+
/release/
13+
14+
# Test artifacts
15+
*.test
16+
*.out
17+
coverage.txt
18+
coverage.html
19+
20+
# Go workspace files
21+
go.work
22+
go.work.sum
23+
24+
# IDE
25+
.idea/
26+
.vscode/
27+
*.swp
28+
*.swo
29+
*~
30+
.DS_Store
31+
32+
# OS files
33+
Thumbs.db
34+
35+
# Dependencies (should be vendored or downloaded)
36+
/vendor/
37+
38+
# Cache
39+
*.cache
40+
.cache/
41+
42+
# Config and credentials (user-specific)
43+
/config/
44+
auth.json
45+
*.cookie
46+
47+
# Logs
48+
*.log
49+
50+
# Temporary files
51+
/tmp/
52+
temp/
53+
54+
# Environment files
55+
.env
56+
.env.local
57+
.env.*.local

CONTRIBUTING.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Contributing to xsh
2+
3+
## Development
4+
5+
### Prerequisites
6+
7+
- Go 1.23 or later
8+
- Make (optional)
9+
10+
### Build
11+
12+
```bash
13+
go build -o xsh main.go
14+
```
15+
16+
### Build with version
17+
18+
```bash
19+
go build -ldflags="-s -w -X github.com/benoitpetit/xsh/cmd.Version=1.0.0" -o xsh main.go
20+
```
21+
22+
### Run tests
23+
24+
```bash
25+
go test ./...
26+
```
27+
28+
### Run with verbose output
29+
30+
```bash
31+
./xsh -v feed
32+
```
33+
34+
## Releasing
35+
36+
### Automatic Release via GitHub Actions
37+
38+
1. Push to `prod` branch for continuous builds
39+
2. Create a tag for official releases:
40+
41+
```bash
42+
git tag -a v1.0.0 -m "Release version 1.0.0"
43+
git push origin v1.0.0
44+
```
45+
46+
The GitHub Actions workflow will automatically:
47+
- Build binaries for Linux, Windows, and macOS (amd64 & arm64)
48+
- Create a GitHub Release with all binaries
49+
- Compress binaries (.tar.gz for Unix, .zip for Windows)
50+
51+
### Manual Release
52+
53+
```bash
54+
# Linux
55+
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o xsh-linux-amd64 main.go
56+
57+
# Windows
58+
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o xsh-windows-amd64.exe main.go
59+
60+
# macOS Intel
61+
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o xsh-darwin-amd64 main.go
62+
63+
# macOS Apple Silicon
64+
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o xsh-darwin-arm64 main.go
65+
```
66+
67+
## Project Structure
68+
69+
```
70+
.
71+
├── browser/ # Browser cookie extraction
72+
├── cmd/ # CLI commands
73+
├── core/ # Core API logic
74+
├── display/ # Output formatting
75+
├── models/ # Data models
76+
├── tests/ # Test suite
77+
├── utils/ # Utilities
78+
└── main.go # Entry point
79+
```
80+
81+
## Code Style
82+
83+
- Follow standard Go conventions
84+
- Run `go fmt` before committing
85+
- Run `go vet` to check for issues
86+
- Add tests for new features

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 xsh contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.PHONY: build test clean release all
2+
3+
VERSION ?= dev
4+
LDFLAGS = -ldflags="-s -w -X github.com/benoitpetit/xsh/cmd.Version=$(VERSION)"
5+
6+
BINARY_NAME = xsh
7+
MAIN_FILE = main.go
8+
9+
# Default build for current platform
10+
build:
11+
go build $(LDFLAGS) -o $(BINARY_NAME) $(MAIN_FILE)
12+
13+
# Build all platforms
14+
all: build-linux build-windows build-darwin
15+
16+
build-linux:
17+
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 $(MAIN_FILE)
18+
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64 $(MAIN_FILE)
19+
20+
build-windows:
21+
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-amd64.exe $(MAIN_FILE)
22+
GOOS=windows GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-arm64.exe $(MAIN_FILE)
23+
24+
build-darwin:
25+
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 $(MAIN_FILE)
26+
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 $(MAIN_FILE)
27+
28+
# Testing
29+
test:
30+
go test ./...
31+
32+
test-v:
33+
go test -v ./...
34+
35+
# Clean build artifacts
36+
clean:
37+
rm -f $(BINARY_NAME)
38+
rm -rf dist/
39+
40+
# Install locally
41+
install:
42+
go install $(LDFLAGS) .
43+
44+
# Development run
45+
dev:
46+
go run $(LDFLAGS) $(MAIN_FILE)
47+
48+
# Lint (requires staticcheck)
49+
lint:
50+
staticcheck ./...
51+
52+
# Format code
53+
fmt:
54+
go fmt ./...
55+
56+
# Check for issues
57+
vet:
58+
go vet ./...
59+
60+
# Full check
61+
check: fmt vet lint test
62+
63+
# Create release directory and build
64+
release: clean
65+
mkdir -p dist
66+
$(MAKE) all VERSION=$(VERSION)
67+
cd dist && for f in *; do if [[ "$$f" == *.exe ]]; then zip "$$f.zip" "$$f"; else tar czf "$$f.tar.gz" "$$f"; fi; done

0 commit comments

Comments
 (0)