Skip to content

Commit 00ced88

Browse files
authored
Merge pull request #2 from vinitkumar/feat/add-github-actions-ci
Feat/add GitHub actions ci
2 parents 54d24c0 + 5a9e072 commit 00ced88

File tree

8 files changed

+184
-67
lines changed

8 files changed

+184
-67
lines changed

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Go CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: macos-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: '1.24.3'
20+
cache: true
21+
22+
- name: Run tests
23+
run: go test -v ./...
24+
25+
build:
26+
name: Build
27+
runs-on: macos-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: '1.24.3'
35+
cache: true
36+
37+
- name: Build
38+
run: go build -v -o pdf-joiner
39+
40+
- name: Upload artifact
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: pdf-joiner
44+
path: pdf-joiner
45+
46+
release:
47+
name: Release
48+
needs: [test, build]
49+
if: startsWith(github.ref, 'refs/tags/v')
50+
runs-on: macos-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Set up Go
55+
uses: actions/setup-go@v5
56+
with:
57+
go-version: '1.24.3'
58+
59+
- name: Build
60+
run: go build -v -o pdf-joiner
61+
62+
- name: Create Release
63+
id: create_release
64+
uses: actions/create-release@v1
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
tag_name: ${{ github.ref }}
69+
release_name: Release ${{ github.ref }}
70+
draft: false
71+
prerelease: false
72+
73+
- name: Upload Release Asset
74+
id: upload-release-asset
75+
uses: actions/upload-release-asset@v1
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
with:
79+
upload_url: ${{ steps.create_release.outputs.upload_url }}
80+
asset_path: ./pdf-joiner
81+
asset_name: pdf-joiner
82+
asset_content_type: application/octet-stream
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
11+
# pull-requests: read
12+
13+
jobs:
14+
golangci:
15+
name: lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: stable
22+
- name: golangci-lint
23+
uses: golangci/golangci-lint-action@v8
24+
with:
25+
version: v2.1

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
pdf-joiner
8+
9+
# Test binary, built with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool
13+
*.out
14+
15+
# Dependency directories (remove the comment below if you'll be checking in your vendor directory)
16+
# vendor/
17+
18+
# Go workspace file
19+
go.work
20+
21+
# macOS specific files
22+
.DS_Store
23+
24+
# IDE files
25+
.idea/
26+
.vscode/
27+
*.swp
28+
*.swo

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 Vinit Kumar
3+
Copyright (c) 2023 Vinit Kumar
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 29 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,62 @@
11
# PDF Joiner
22

3-
A simple command-line utility for joining multiple PDF files into a single PDF document on macOS.
3+
[![Go CI](https://github.com/vinitkumar/pdf-joiner/actions/workflows/ci.yml/badge.svg)](https://github.com/vinitkumar/pdf-joiner/actions/workflows/ci.yml)
4+
5+
A simple command-line tool to join multiple PDF files into a single PDF document on macOS.
46

57
## Requirements
68

7-
- macOS (This tool uses the built-in macOS PDF joining utility)
8-
- Go 1.18 or later (for building from source)
9+
- macOS (the tool uses the built-in macOS PDF joining utility)
10+
- Go 1.24 or higher (for development)
911

1012
## Installation
1113

1214
### From Source
1315

14-
1. Clone this repository:
15-
```
16-
git clone https://github.com/vinitkumar/pdf-joiner.git
17-
cd pdf-joiner
18-
```
19-
20-
2. Build the binary:
21-
```
22-
make build
23-
```
24-
25-
3. (Optional) Install the binary to your system:
26-
```
27-
make install
28-
```
29-
30-
## Usage
31-
16+
```bash
17+
git clone https://github.com/vinitkumar/pdf-joiner.git
18+
cd pdf-joiner
19+
go build -o pdf-joiner
3220
```
33-
pdf-joiner [-o output.pdf] file1.pdf file2.pdf [file3.pdf ...]
34-
```
35-
36-
### Options
3721

38-
- `-o`: Specify the output file path. If not provided, the output will be saved as `joined-pdf-YYYY-MM-DD-HHMMSS.pdf` in the current directory.
22+
### From Releases
3923

40-
### Examples
24+
Download the latest binary from the [Releases page](https://github.com/vinitkumar/pdf-joiner/releases).
4125

42-
Join two PDF files:
43-
```
44-
pdf-joiner file1.pdf file2.pdf
45-
```
26+
## Usage
4627

47-
Join multiple PDF files with a specific output path:
48-
```
49-
pdf-joiner -o merged.pdf file1.pdf file2.pdf file3.pdf
50-
```
28+
```bash
29+
# Join PDFs with default output filename (timestamp-based)
30+
./pdf-joiner file1.pdf file2.pdf file3.pdf
5131

52-
Join all PDF files in a directory:
53-
```
54-
pdf-joiner -o merged.pdf /path/to/directory/*.pdf
32+
# Join PDFs with a custom output filename
33+
./pdf-joiner -o output.pdf file1.pdf file2.pdf file3.pdf
5534
```
5635

57-
## How It Works
36+
## Features
5837

59-
This tool is a wrapper around the macOS built-in PDF joining utility located at:
60-
```
61-
/System/Library/Automator/Combine PDF Pages.action/Contents/MacOS/join
62-
```
38+
- Join multiple PDF files into a single document
39+
- Specify custom output path
40+
- Automatic output filename generation with timestamp
41+
- Verification of input files
6342

6443
## Development
6544

66-
### Running Tests
45+
### Testing
6746

68-
```
69-
make test
47+
```bash
48+
go test -v ./...
7049
```
7150

72-
### Building for Different Architectures
51+
### Building
7352

74-
Build for both Intel and Apple Silicon Macs:
75-
```
76-
make build-universal-darwin
77-
```
78-
79-
### Cleaning Up
80-
81-
```
82-
make clean
53+
```bash
54+
go build -o pdf-joiner
8355
```
8456

8557
## License
8658

87-
MIT. See the `LICENSE` file for more details.
59+
MIT
8860

8961
## Author
9062

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/vinitkumar/pdf-joiner
22

3-
go 1.24.0
3+
go 1.24.3

go.sum

Whitespace-only changes.

main_test.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ func TestFileExists(t *testing.T) {
1212
if err != nil {
1313
t.Fatalf("Failed to create temporary file: %v", err)
1414
}
15-
defer os.Remove(tempFile.Name())
16-
defer tempFile.Close()
15+
defer func() {
16+
if err := tempFile.Close(); err != nil {
17+
t.Logf("Failed to close temporary file: %v", err)
18+
}
19+
if err := os.Remove(tempFile.Name()); err != nil {
20+
t.Logf("Failed to remove temporary file: %v", err)
21+
}
22+
}()
1723

1824
// Test cases
1925
tests := []struct {
@@ -52,25 +58,29 @@ func TestFileExists(t *testing.T) {
5258
func TestOutputPathGeneration(t *testing.T) {
5359
// This is a mock test to demonstrate how we would test the output path generation
5460
// In a real test, we would need to mock time.Now() or use dependency injection
55-
61+
5662
// Create a temporary directory for testing
5763
tempDir, err := os.MkdirTemp("", "pdf-joiner-test")
5864
if err != nil {
5965
t.Fatalf("Failed to create temporary directory: %v", err)
6066
}
61-
defer os.RemoveAll(tempDir)
62-
67+
defer func() {
68+
if err := os.RemoveAll(tempDir); err != nil {
69+
t.Logf("Failed to remove temporary directory: %v", err)
70+
}
71+
}()
72+
6373
// Test that we can create directories for output
6474
testOutputPath := filepath.Join(tempDir, "subdir", "output.pdf")
6575
outputDir := filepath.Dir(testOutputPath)
66-
76+
6777
err = os.MkdirAll(outputDir, 0755)
6878
if err != nil {
6979
t.Errorf("Failed to create output directory: %v", err)
7080
}
71-
81+
7282
// Verify the directory was created
7383
if _, err := os.Stat(outputDir); os.IsNotExist(err) {
7484
t.Errorf("Output directory was not created: %v", err)
7585
}
76-
}
86+
}

0 commit comments

Comments
 (0)