Skip to content

Daily Build Zotero PDF.js Types #191

Daily Build Zotero PDF.js Types

Daily Build Zotero PDF.js Types #191

Workflow file for this run

name: Daily Build Zotero PDF.js Types
on:
push:
branches:
- main
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
check:
name: Check if pdf.js changed
runs-on: ubuntu-latest
outputs:
commit_hash: ${{ steps.get-latest-commit.outputs.short_commit }}
need_build: ${{ steps.cache-hash.outputs.cache-hit != 'true' }}
steps:
- name: Get latest commit hash from Zotero/pdf.js
id: get-latest-commit
run: |
latest_commit=$(git ls-remote https://github.com/zotero/pdf.js.git HEAD | cut -f1)
echo "latest_commit=$latest_commit" >> $GITHUB_OUTPUT
echo "short_commit=${latest_commit:0:7}" >> $GITHUB_OUTPUT
- name: Cache commit hash
id: cache-hash
uses: actions/cache@v5
with:
path: last_commit
key: zotero-pdfjs-commit-${{ steps.get-latest-commit.outputs.latest_commit }}
- name: Save new commit hash
if: ${{ steps.cache-hash.outputs.cache-hit != 'true' }}
run: |
echo "${{ steps.get-latest-commit.outputs.latest_commit }}" > last_commit
build:
name: Build pdf.js & upload types
needs: check
if: ${{ needs.check.outputs.need_build == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Zotero/pdf.js
uses: actions/checkout@v6
with:
repository: zotero/pdf.js
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: npm
- name: Install dependencies
run: npm install
- name: Build pdf.js (gulp dist)
run: npx gulp dist
- name: Upload types artifact
uses: actions/upload-artifact@v6
with:
name: pdfjs-types
path: build/types
if-no-files-found: error
commit:
name: Commit updated types
needs: [check, build]
if: ${{ needs.check.outputs.need_build == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout zotero-pdfjs-types repo
uses: actions/checkout@v6
- name: Download built types
uses: actions/download-artifact@v7
with:
name: pdfjs-types
path: types
- name: Commit and push changes
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions[bot]
author_email: github-actions[bot]@users.noreply.github.com
message: "feat: update pdf.js types to commit ${{ needs.check.outputs.commit_hash }}"
add: "types"
# publish:
# name: Publish to npm
# needs: build
# if: ${{ needs.check.outputs.need_build == 'true' }}
# runs-on: ubuntu-latest
# permissions:
# contents: read
# id-token: write
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 20
# registry-url: "https://registry.npmjs.org/"
# - name: Bump patch version
# run: |
# current_version=$(node -p "require('./package.json').version")
# new_version=$(node -p "const [M,m,p]=require('./package.json').version.split('.').map(Number);[M,m,p+1].join('.') ")
# npm version $new_version --no-git-tag-version
# git add package.json
# git commit -m "chore: bump version to $new_version"
# git push
# - name: Publish package
# run: npm publish --access public
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}