chore: Bump version to 0.3.0 and update CHANGELOG #25
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI, Publish & Release | |
| on: | |
| push: | |
| branches: | |
| - main # Trigger on push to main branch | |
| tags: | |
| - 'v*.*.*' # Trigger on push of version tags (e.g., v0.5.5) | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| artifact_name: build-artifacts-archive # Consistent name for upload/download | |
| archive_filename: ${{ steps.archive_build.outputs.archive_name }} # Actual .tar.gz filename | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Get package version | |
| id: get_version | |
| # Use tag name if available, otherwise use package.json version | |
| run: | | |
| VERSION="" | |
| if [[ "${{ github.ref_type }}" == "tag" && "${{ github.ref }}" == refs/tags/v* ]]; then | |
| VERSION=$(echo "${{ github.ref }}" | sed 's#refs/tags/##') | |
| else | |
| # Fallback for main branch pushes or if tag logic fails | |
| VERSION=$(node -p "require('./package.json').version")-SNAPSHOT | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # --- Conditional Artifact Archiving and Upload --- | |
| - name: Archive build artifacts (only on tag push) | |
| if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags | |
| id: archive_build | |
| run: | | |
| tar -czf build-artifacts.tar.gz build package.json package-lock.json README.md CHANGELOG.md LICENSE Dockerfile .dockerignore | |
| echo "archive_name=build-artifacts.tar.gz" >> $GITHUB_OUTPUT | |
| - name: Upload build artifacts (only on tag push) | |
| if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ job.outputs.artifact_name }} # Use consistent name from job outputs | |
| path: ${{ steps.archive_build.outputs.archive_name }} | |
| publish-npm: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags | |
| steps: | |
| - name: Download build artifacts archive | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.build.outputs.artifact_name }} # Use consistent artifact name | |
| path: . | |
| - name: Extract build artifacts | |
| run: tar -xzf ${{ needs.build.outputs.archive_filename }} # Use the correct archive filename from build job | |
| - name: Set up Node.js for npm publish | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org/' | |
| - name: Publish to npm | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| publish-docker: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags | |
| steps: | |
| - name: Download build artifacts archive | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.build.outputs.artifact_name }} # Use consistent artifact name | |
| path: . | |
| - name: Extract build artifacts | |
| run: tar -xzf ${{ needs.build.outputs.archive_filename }} # Use the correct archive filename from build job | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: shtse8/pdf-reader-mcp # Ensure this is the correct image name | |
| # Use version from the build job output (which is derived from the tag) | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ needs.build.outputs.version }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ needs.build.outputs.version }} | |
| type=sha,prefix=,suffix=,event=tag | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} # Add latest tag for main and version tags | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . # Context is the directory with extracted artifacts | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| create-release: | |
| needs: [build, publish-npm, publish-docker] # Depend on build and both publish jobs | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') # Condition: Only run for tags | |
| permissions: | |
| contents: write # Need permission to create releases | |
| steps: | |
| - name: Download build artifacts archive | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.build.outputs.artifact_name }} # Use consistent artifact name | |
| path: . | |
| - name: Extract build artifacts | |
| run: tar -xzf ${{ needs.build.outputs.archive_filename }} # Use the correct archive filename from build job | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: Release ${{ github.ref_name }} | |
| body_path: CHANGELOG.md # Assumes CHANGELOG.md is in the artifact root | |
| # files: ${{ needs.build.outputs.archive_filename }} # Optional: Attach the full archive to the release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |