Skip to content

Commit 3412a07

Browse files
committed
feat: Add CHANGELOG, LICENSE and improve release workflow
Added standard CHANGELOG.md and MIT LICENSE files. Updated GitHub Actions workflow to trigger on main/tags, conditionally publish artifacts and jobs, and create GitHub releases using the changelog.
1 parent 742eed2 commit 3412a07

File tree

5 files changed

+145
-66
lines changed

5 files changed

+145
-66
lines changed

.github/workflows/publish.yml

Lines changed: 85 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
name: Build and Publish
1+
name: CI, Publish & Release
22

33
on:
44
push:
5+
branches:
6+
- main # Trigger on push to main branch
57
tags:
6-
- 'v*.*.*' # Trigger on version tags like v0.1.0, v1.2.3
8+
- 'v*.*.*' # Trigger on push of version tags (e.g., v0.5.5)
79

810
jobs:
911
build:
1012
runs-on: ubuntu-latest
1113
outputs:
12-
package_version: ${{ steps.get_version.outputs.version }} # Output version for other jobs
14+
version: ${{ steps.get_version.outputs.version }}
15+
artifact_name: build-artifacts-archive # Consistent name for upload/download
16+
archive_filename: ${{ steps.archive_build.outputs.archive_name }} # Actual .tar.gz filename
1317
steps:
1418
- name: Checkout repository
1519
uses: actions/checkout@v4
@@ -27,58 +31,70 @@ jobs:
2731

2832
- name: Get package version
2933
id: get_version
30-
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
31-
32-
- name: Upload build artifacts
34+
# Use tag name if available, otherwise use package.json version
35+
run: |
36+
VERSION=""
37+
if [[ "${{ github.ref_type }}" == "tag" && "${{ github.ref }}" == refs/tags/v* ]]; then
38+
VERSION=$(echo "${{ github.ref }}" | sed 's#refs/tags/##')
39+
else
40+
# Fallback for main branch pushes or if tag logic fails
41+
VERSION=$(node -p "require('./package.json').version")-SNAPSHOT
42+
fi
43+
echo "version=$VERSION" >> $GITHUB_OUTPUT
44+
45+
# --- Conditional Artifact Archiving and Upload ---
46+
- name: Archive build artifacts (only on tag push)
47+
if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags
48+
id: archive_build
49+
run: |
50+
tar -czf build-artifacts.tar.gz build package.json package-lock.json README.md CHANGELOG.md LICENSE Dockerfile .dockerignore
51+
echo "archive_name=build-artifacts.tar.gz" >> $GITHUB_OUTPUT
52+
53+
- name: Upload build artifacts (only on tag push)
54+
if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags
3355
uses: actions/upload-artifact@v4
3456
with:
35-
name: build-artifacts
36-
path: |
37-
build/
38-
package.json
39-
package-lock.json
40-
README.md
41-
Dockerfile # Include Dockerfile if needed for docker build context
42-
# Add any other files needed by publish jobs
57+
name: ${{ job.outputs.artifact_name }} # Use consistent name from job outputs
58+
path: ${{ steps.archive_build.outputs.archive_name }}
4359

4460
publish-npm:
45-
needs: build # Depends on the build job
61+
needs: build
4662
runs-on: ubuntu-latest
47-
# Removed if condition, now triggered by tag push
63+
if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags
4864
steps:
49-
- name: Set up Node.js
65+
- name: Download build artifacts archive
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: ${{ needs.build.outputs.artifact_name }} # Use consistent artifact name
69+
path: .
70+
71+
- name: Extract build artifacts
72+
run: tar -xzf ${{ needs.build.outputs.archive_filename }} # Use the correct archive filename from build job
73+
74+
- name: Set up Node.js for npm publish
5075
uses: actions/setup-node@v4
5176
with:
5277
node-version: '20'
5378
registry-url: 'https://registry.npmjs.org/'
5479

55-
- name: Download build artifacts
56-
uses: actions/download-artifact@v4
57-
with:
58-
name: build-artifacts
59-
path: . # Download to current directory
60-
61-
# Optional: Verify downloaded files if needed
62-
# - run: ls -la
63-
6480
- name: Publish to npm
6581
run: npm publish --access public
6682
env:
6783
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6884

6985
publish-docker:
70-
needs: build # Depends on the build job
86+
needs: build
7187
runs-on: ubuntu-latest
72-
# Removed if condition, now triggered by tag push
88+
if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags
7389
steps:
74-
- name: Checkout repository (needed for git sha tag)
75-
uses: actions/checkout@v4
76-
77-
- name: Download build artifacts
90+
- name: Download build artifacts archive
7891
uses: actions/download-artifact@v4
7992
with:
80-
name: build-artifacts
81-
path: . # Download to current directory, overwriting local files if necessary
93+
name: ${{ needs.build.outputs.artifact_name }} # Use consistent artifact name
94+
path: .
95+
96+
- name: Extract build artifacts
97+
run: tar -xzf ${{ needs.build.outputs.archive_filename }} # Use the correct archive filename from build job
8298

8399
- name: Set up QEMU
84100
uses: docker/setup-qemu-action@v3
@@ -96,21 +112,46 @@ jobs:
96112
id: meta
97113
uses: docker/metadata-action@v5
98114
with:
99-
images: shtse8/pdf-reader-mcp # *** UPDATED IMAGE NAME ***
115+
images: shtse8/pdf-reader-mcp # Ensure this is the correct image name
116+
# Use version from the build job output (which is derived from the tag)
100117
tags: |
101-
type=schedule
102-
type=ref,event=branch
103-
type=ref,event=pr
104-
type=semver,pattern={{version}},value=${{ needs.build.outputs.package_version }} # Use version from build job
105-
type=semver,pattern={{major}}.{{minor}},value=${{ needs.build.outputs.package_version }}
106-
type=sha # Add git sha tag
118+
type=semver,pattern={{version}},value=${{ needs.build.outputs.version }}
119+
type=semver,pattern={{major}}.{{minor}},value=${{ needs.build.outputs.version }}
120+
type=sha,prefix=,suffix=,event=tag
121+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} # Add latest tag for main and version tags
107122
108123
- name: Build and push Docker image
109124
uses: docker/build-push-action@v6
110125
with:
111-
context: . # Context now includes downloaded artifacts + checked out repo files
112-
push: true # Already checked condition in 'if'
126+
context: . # Context is the directory with extracted artifacts
127+
push: true
113128
tags: ${{ steps.meta.outputs.tags }}
114129
labels: ${{ steps.meta.outputs.labels }}
115130
cache-from: type=gha
116-
cache-to: type=gha,mode=max
131+
cache-to: type=gha,mode=max
132+
133+
create-release:
134+
needs: [build, publish-npm, publish-docker] # Depend on build and both publish jobs
135+
runs-on: ubuntu-latest
136+
if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags
137+
permissions:
138+
contents: write # Need permission to create releases
139+
steps:
140+
- name: Download build artifacts archive
141+
uses: actions/download-artifact@v4
142+
with:
143+
name: ${{ needs.build.outputs.artifact_name }} # Use consistent artifact name
144+
path: .
145+
146+
- name: Extract build artifacts
147+
run: tar -xzf ${{ needs.build.outputs.archive_filename }} # Use the correct archive filename from build job
148+
149+
- name: Create GitHub Release
150+
uses: softprops/action-gh-release@v2
151+
with:
152+
tag_name: ${{ github.ref_name }}
153+
name: Release ${{ github.ref_name }}
154+
body_path: CHANGELOG.md # Assumes CHANGELOG.md is in the artifact root
155+
# files: ${{ needs.build.outputs.archive_filename }} # Optional: Attach the full archive to the release
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Initial project setup based on filesystem-mcp.
12+
- Core `read_pdf` tool using `pdfjs-dist` library.
13+
- Support for reading text, metadata, and page count.
14+
- Support for local file paths and URLs.
15+
- Support for processing multiple sources in one call with per-source page selection.
16+
- Basic README and Memory Bank documentation.
17+
- Dockerfile and .dockerignore.
18+
- GitHub Actions workflow for publishing (initial version).

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) 2025 [Your Name or Organization]
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.

memory-bank/activeContext.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- Version: 1.0 | Last Updated: 2025-04-05 | Updated By: Cline -->
2+
13
# Active Context: PDF Reader MCP Server (Initial Setup)
24

35
## 1. Current Focus
@@ -23,15 +25,18 @@ implementing the core PDF reading tools based on the `filesystem-mcp` template.
2325
parameter into each source object, allowing different page selections for
2426
different files in the same request. Updated `README.md` and Memory Bank files
2527
again.
28+
- Created `CHANGELOG.md` with initial structure.
29+
- Created `LICENSE` file (MIT License).
30+
- Updated `.github/workflows/publish.yml` to include main branch trigger, conditional artifact creation/upload, conditional job execution based on tags, and a `create-release` job using `CHANGELOG.md`.
2631

2732
## 3. Next Steps
2833

29-
- Update `memory-bank/progress.md` to reflect tool consolidation.
30-
- Build the project (`npm run build`) again after adding multi-source support.
34+
- Update `memory-bank/progress.md` to reflect recent changes (Changelog, License, Workflow).
35+
- Build the project (`npm run build`).
36+
- Test the updated GitHub Actions workflow by pushing a tag (e.g., `v0.3.0`).
3137
- Consider adding basic tests for the PDF handlers.
32-
- Commit the initial implementation to the Git repository.
33-
- Potentially test the server using `@modelcontextprotocol/inspector` or by
34-
integrating with Cline.
38+
- Commit changes to the Git repository.
39+
- Potentially test the server using `@modelcontextprotocol/inspector` or by integrating with Cline.
3540

3641
## 4. Active Decisions & Considerations
3742

memory-bank/progress.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- Version: 1.0 | Last Updated: 2025-04-05 | Updated By: Cline -->
2+
13
# Progress: PDF Reader MCP Server (Initial Implementation)
24

35
## 1. What Works
@@ -14,32 +16,24 @@
1416
- **Documentation:**
1517
- `README.md`: Updated with PDF tool descriptions.
1618
- Memory Bank: Core files created/updated with initial context.
19+
- **Changelog:** `CHANGELOG.md` created with initial structure.
20+
- **License:** `LICENSE` file created (MIT).
21+
- **GitHub Actions:** `.github/workflows/publish.yml` updated to trigger on main/tags, conditionally publish, and create releases using `CHANGELOG.md`.
1722

1823
## 2. What's Left to Build/Verify
1924

20-
- **Compilation:** Need to run `npm run build` again after moving `pages`
21-
parameter.
25+
- **Compilation:** Need to run `npm run build`.
2226
- **Runtime Testing:**
2327
- Verify the server starts correctly.
24-
- Test the consolidated `read_pdf` tool with various parameter combinations,
25-
multiple sources, and per-source `pages` specifications via
26-
`@modelcontextprotocol/inspector` or a live agent. Verify the `results`
27-
array structure and error handling per source.
28-
- Specifically test `read_pdf` with the `pages` parameter for different page
29-
ranges and edge cases across multiple sources.
30-
- Verify error handling (e.g., file not found, URL fetch errors, corrupted
31-
PDF).
32-
- **Testing Framework:** Consider adding automated tests (e.g., using Jest or
33-
Vitest) for handlers.
28+
- Test the consolidated `read_pdf` tool via `@modelcontextprotocol/inspector` or a live agent.
29+
- Verify error handling (e.g., file not found, URL fetch errors, corrupted PDF).
30+
- **Testing Framework:** Consider adding automated tests (e.g., using Jest or Vitest) for handlers.
3431
- **Refinement:** Review code for potential improvements or edge cases missed.
35-
- **Publishing Setup:** Ensure GitHub Actions workflow in
36-
`.github/workflows/publish.yml` is correctly configured for the new package
37-
name and Docker image name (if not already done).
32+
- **Publishing Workflow Test:** Test the updated GitHub Actions workflow by pushing a version tag (e.g., `v0.3.0`) and verifying npm/Docker publish and GitHub Release creation.
3833

3934
## 3. Current Status
4035

41-
Moved `pages` parameter to be per-source in `read_pdf` handler. Documentation
42-
updated. Ready for final build and testing.
36+
Added `CHANGELOG.md`, `LICENSE`. Updated GitHub Actions workflow for improved release process. Ready for build and testing, including workflow verification.
4337

4438
## 4. Known Issues/Risks
4539

0 commit comments

Comments
 (0)