Skip to content

Commit ac5428d

Browse files
committed
Improve CI
1 parent fbd6069 commit ac5428d

File tree

8 files changed

+265
-18
lines changed

8 files changed

+265
-18
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
/ffbookmarks-to-markdown
3+
/ffsclient

.envrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dotenv
22

3-
export PATH=$PATH:$PWD/.bin
3+
export PATH=$PATH:$PWD

.github/workflows/ci.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on: push
4+
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0 # Needed for git describe to work properly
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.23'
21+
cache: true
22+
23+
- name: Build
24+
run: |
25+
# Build for each supported platform
26+
GOOS=linux GOARCH=amd64 make build
27+
GOOS=linux GOARCH=arm64 make build
28+
GOOS=darwin GOARCH=amd64 make build
29+
30+
- name: Create release
31+
if: startsWith(github.ref, 'refs/tags/')
32+
run: |
33+
# Build for each supported platform
34+
GOOS=linux GOARCH=amd64 make release
35+
GOOS=linux GOARCH=arm64 make release
36+
GOOS=darwin GOARCH=amd64 make release
37+
38+
- name: Push Release
39+
uses: softprops/action-gh-release@v2
40+
if: startsWith(github.ref, 'refs/tags/')
41+
with:
42+
files: |
43+
build/*.tar.gz
44+
build/*.sha256
45+
generate_release_notes: true

.github/workflows/docker.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
- main
77
tags:
88
- 'v*'
9-
pull_request:
10-
branches:
11-
- main
129

1310
env:
1411
REGISTRY: ghcr.io
@@ -25,6 +22,9 @@ jobs:
2522
- name: Checkout repository
2623
uses: actions/checkout@v4
2724

25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v3
27+
2828
- name: Set up Docker Buildx
2929
uses: docker/setup-buildx-action@v3
3030

@@ -52,6 +52,7 @@ jobs:
5252
uses: docker/build-push-action@v5
5353
with:
5454
context: .
55+
platforms: linux/amd64,linux/arm64
5556
push: ${{ github.event_name != 'pull_request' }}
5657
tags: ${{ steps.meta.outputs.tags }}
5758
labels: ${{ steps.meta.outputs.labels }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.env
22
.bin
33
/bookmarks
4+
/build
5+
/ffbookmarks-to-markdown
6+
/ffsclient

Dockerfile

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Build stage
2-
FROM golang:1.23-bullseye AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.23-bullseye AS builder
33

4-
WORKDIR /app
5-
6-
# Install ffsclient
7-
ADD https://github.com/Mikescher/firefox-sync-client/releases/download/v1.8.0/ffsclient_linux-amd64-static /usr/local/bin/ffsclient
8-
RUN chmod +x /usr/local/bin/ffsclient
4+
WORKDIR /build
95

106
# Copy go mod files
117
COPY go.mod go.sum ./
@@ -15,14 +11,15 @@ RUN go mod download
1511
COPY . .
1612

1713
# Build the application with static linking
18-
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags='-w -s -extldflags "-static"' -o /ffbookmarks-to-markdown ./cmd/main.go
14+
ARG TARGETARCH
15+
RUN GOARCH=$TARGETARCH make install
1916

2017
# Final stage
21-
FROM gcr.io/distroless/static-debian12:nonroot
18+
FROM --platform=$TARGETPLATFORM gcr.io/distroless/static-debian12:nonroot
2219

2320
# Copy the binary and ffsclient
24-
COPY --from=builder /ffbookmarks-to-markdown /ffbookmarks-to-markdown
25-
COPY --from=builder /usr/local/bin/ffsclient /usr/local/bin/ffsclient
21+
COPY --from=builder /build/build/ffbookmarks-to-markdown-linux-* /ffbookmarks-to-markdown
22+
COPY --from=builder /build/build/ffsclient-* /usr/local/bin/ffsclient
2623

2724
# Use nonroot user
2825
USER nonroot:nonroot

Makefile

+79-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,79 @@
1-
ffsclient:
2-
mkdir -p .bin
3-
curl -L -o .bin/ffsclient https://github.com/Mikescher/firefox-sync-client/releases/download/v1.8.0/ffsclient_linux-amd64-static
4-
chmod +x .bin/ffsclient
1+
# Build parameters
2+
BINARY_NAME=ffbookmarks-to-markdown
3+
MAIN_FILE=cmd/main.go
4+
BUILD_DIR=build
5+
6+
# Default OS/ARCH
7+
GOOS?=linux
8+
GOARCH?=amd64
9+
10+
# Version from git tag
11+
VERSION?=$(shell git describe --tags --always --dirty)
12+
13+
# ffsclient parameters
14+
FFSCLIENT_VERSION=v1.8.0
15+
16+
# Build flags
17+
LDFLAGS=-w -s -X main.version=$(VERSION) -extldflags "-static"
18+
19+
# Get all Go source files
20+
GO_FILES=$(shell go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}} {{range .TestGoFiles}}{{$$.Dir}}/{{.}} {{end}} {{range .XTestGoFiles}}{{$$.Dir}}/{{.}} {{end}}' ./...)
21+
22+
OUT?=.
23+
IMG?=$(BINARY_NAME):$(VERSION)
24+
TARGET=$(BUILD_DIR)/$(BINARY_NAME)-$(GOOS)-$(GOARCH)
25+
RELEASE_TARGET=$(BUILD_DIR)/$(BINARY_NAME)-$(GOOS)-$(GOARCH).tar.gz
26+
FFSCLIENT_TARGET=$(BUILD_DIR)/ffsclient-$(GOOS)-$(GOARCH)-$(FFSCLIENT_VERSION)
27+
28+
.PHONY: build clean release ffsclient install container
29+
30+
build: $(TARGET)
31+
release: $(RELEASE_TARGET)
32+
ffsclient: $(FFSCLIENT_TARGET)
33+
install: $(TARGET) $(FFSCLIENT_TARGET)
34+
install -m 755 $(TARGET) $(OUT)/$(BINARY_NAME)
35+
install -m 755 $(FFSCLIENT_TARGET) $(OUT)/ffsclient
36+
37+
# Download and install ffsclient
38+
$(FFSCLIENT_TARGET):
39+
@echo "Downloading ffsclient $(FFSCLIENT_VERSION) for $(GOOS)/$(GOARCH)..."
40+
@mkdir -p $(BUILD_DIR)
41+
@case "$(GOOS)-$(GOARCH)" in \
42+
"linux-amd64") \
43+
URL="https://github.com/Mikescher/firefox-sync-client/releases/download/$(FFSCLIENT_VERSION)/ffsclient_linux-amd64-static" ;; \
44+
"linux-arm64") \
45+
URL="https://github.com/Mikescher/firefox-sync-client/releases/download/$(FFSCLIENT_VERSION)/ffsclient_linux-arm64-static" ;; \
46+
"darwin-amd64") \
47+
URL="https://github.com/Mikescher/firefox-sync-client/releases/download/$(FFSCLIENT_VERSION)/ffsclient_macos-amd64" ;; \
48+
*) echo "Unsupported OS/ARCH: $(GOOS)-$(GOARCH)" && exit 1 ;; \
49+
esac && curl --fail -L -o $(FFSCLIENT_TARGET) $$URL
50+
@chmod +x $(FFSCLIENT_TARGET)
51+
52+
# Default build
53+
$(TARGET): $(GO_FILES)
54+
@echo "Building for $(GOOS)/$(GOARCH)..."
55+
@mkdir -p $(BUILD_DIR)
56+
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) \
57+
go build -ldflags='$(LDFLAGS)' -o $(TARGET) $(MAIN_FILE)
58+
59+
# Create release archive
60+
$(RELEASE_TARGET): $(TARGET) $(FFSCLIENT_TARGET)
61+
@echo "Creating release archive for $(GOOS)/$(GOARCH)..."
62+
@tar -C $(BUILD_DIR) \
63+
--transform='s|-$(GOOS)-$(GOARCH)-v[0-9.]*||' \
64+
--transform='s|-$(GOOS)-$(GOARCH)||' \
65+
-cvzf $(RELEASE_TARGET) $(notdir $(TARGET)) $(notdir $(FFSCLIENT_TARGET))
66+
@sha256sum $(RELEASE_TARGET) > $(RELEASE_TARGET).sha256
67+
68+
container:
69+
if [ -n "$(shell which docker)" ]; then \
70+
podman build --platform linux/amd64,linux/arm64 -t $(IMG) .; \
71+
elif [ -n "$(shell which podman)" ]; then \
72+
docker buildx build --platform linux/amd64,linux/arm64 -t $(IMG) .; \
73+
else \
74+
echo "No container tool found"; \
75+
fi
76+
77+
# Clean build directory
78+
clean:
79+
@rm -rf $(BUILD_DIR)

README.md

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Firefox Bookmarks to Markdown
2+
3+
A tool that syncs Firefox bookmarks to markdown files for use with tools like Obsidian.
4+
5+
- **Firefox Sync Integration**: Syncs bookmarks directly from Firefox Sync service using [ffsclient](https://github.com/Mikescher/firefox-sync-client)
6+
- **Content download**:
7+
- Downloads content from the web using [markdowner](https://md.dhr.wtf/dashboard) service
8+
- Special handing for github repositories and youtube videos
9+
- **Content Processing**:
10+
- Markdown cleanup using LLM (gemini)
11+
- Fixes relative links
12+
- Preserves code blocks and technical content
13+
- **Screenshots**: Captures website screenshots using [gowitness](https://github.com/sensepost/gowitness)
14+
- **Caching**: Caches web content and LLM responses for efficiency
15+
- **Obsidian Integration**:
16+
- Creates year-based index files
17+
- Adds proper frontmatter
18+
- Compatible with Dataview plugin
19+
20+
## Usage
21+
22+
### Basic Usage
23+
24+
+++ bash
25+
# Sync bookmarks from Firefox toolbar folder
26+
ffbookmarks-to-markdown -folder toolbar -output bookmarks
27+
28+
# List available bookmarks
29+
ffbookmarks-to-markdown -list
30+
31+
# Enable verbose logging
32+
ffbookmarks-to-markdown -verbose
33+
+++
34+
35+
### Advanced Options
36+
37+
+++ bash
38+
# Ignore specific folders
39+
ffbookmarks-to-markdown -ignore "Archive,Old Stuff"
40+
41+
# Use custom LLM settings
42+
ffbookmarks-to-markdown -llm-key "your-key" -llm-model "your-model"
43+
44+
# Use custom screenshot API
45+
ffbookmarks-to-markdown -screenshot-api "https://your-screenshot-service"
46+
+++
47+
48+
## Running Locally
49+
50+
1. Install Go 1.21 or later
51+
2. Clone the repository
52+
3. Install ffsclient:
53+
+++ bash
54+
# Download ffsclient
55+
curl -L -o ffsclient https://github.com/Mikescher/firefox-sync-client/releases/download/v1.8.0/ffsclient_linux-amd64-static
56+
chmod +x ffsclient
57+
sudo mv ffsclient /usr/local/bin/
58+
+++
59+
4. Build and run:
60+
+++ bash
61+
go build -o ffbookmarks-to-markdown ./cmd/main.go
62+
./ffbookmarks-to-markdown -folder toolbar -output bookmarks
63+
+++
64+
65+
## Running with Podman
66+
67+
1. Create required volumes:
68+
+++ bash
69+
# Create volume for Firefox Sync credentials
70+
podman volume create firefox-sync-creds
71+
72+
# Create volume for bookmarks output
73+
podman volume create bookmarks
74+
75+
# Create volume for cache
76+
podman volume create ffbookmarks-cache
77+
+++
78+
79+
2. Copy Firefox Sync credentials:
80+
+++ bash
81+
# Get Firefox Sync credentials from your browser
82+
# ~/.mozilla/firefox/PROFILE/logins.json
83+
# Copy credentials to volume
84+
podman cp ~/.mozilla/firefox/YOUR_PROFILE/logins.json \
85+
firefox-sync-creds:/root/.mozilla/firefox/PROFILE/
86+
+++
87+
88+
3. Run the container:
89+
+++ bash
90+
podman run -it --rm \
91+
-v firefox-sync-creds:/root/.mozilla/firefox:ro \
92+
-v bookmarks:/bookmarks \
93+
-v ffbookmarks-cache:/root/.cache \
94+
-e GEMINI_API_KEY="your-key" \
95+
ghcr.io/xtruder/ffbookmarks-to-markdown:latest \
96+
-folder toolbar -output /bookmarks
97+
+++
98+
99+
## Environment Variables
100+
101+
- `GEMINI_API_KEY`: API key for Gemini LLM service (optional)
102+
103+
## Output Structure
104+
105+
The tool creates the following structure in your output directory:
106+
107+
+++ text
108+
bookmarks/
109+
├── 2024.md # Year index
110+
├── 2023.md # Year index
111+
└── folder/ # Bookmark folders
112+
└── bookmark.md # Bookmark files
113+
+++
114+
115+
Each bookmark file contains:
116+
- Frontmatter with metadata
117+
- Cleaned markdown content
118+
- Screenshot (if available)
119+
- Original URL and creation date
120+
121+
## License
122+
123+
MIT License

0 commit comments

Comments
 (0)