From 927471a9651a84db01608936a320547cef402fd8 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Fri, 25 Oct 2024 15:02:40 +0800 Subject: [PATCH 01/24] feat: publish layer using github actions --- .github/workflows/build.yml | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fc0f4e0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,60 @@ +name: Build + +on: + push: + pull_request: + release: + types: [published] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + container: amazonlinux:2 + steps: + - name: Install the necessary tools + run: | + yum update -y + yum groupinstall "Development Tools" -y + yum install -y tar wget + + - name: Download MuPDF + run: | + wget https://mupdf.com/downloads/archive/mupdf-1.19.0-source.tar.xz + tar -xf mupdf-1.19.0-source.tar.xz + cd mupdf-1.19.0-source + + - name: Build MuPDF + run: | + make build=release + + - name: Create the layer + run: | + mkdir -p layer/bin + cp build/release/mutool layer/bin/ + cd layer + zip -r9 ../mutool-layer.zip . + cd .. + + - name: Upload the layer to the github artifact + uses: actions/upload-artifact@v4 + with: + name: mutool-layer + path: mutool-layer.zip + + - name: Login to AWS + run: | + aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} + aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws configure set region ${{ secrets.AWS_REGION }} + + - name: Deploy the layer to the artifact registry + run: | + aws lambda publish-layer-version \ + --layer-name mutool-layer \ + --zip-file fileb://mutool-layer.zip \ + --compatible-runtimes nodejs20.x + --region ${{ secrets.AWS_REGION }} From 3b099f34710fbdcb0338307ed57f6a1b24212357 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Fri, 25 Oct 2024 15:06:08 +0800 Subject: [PATCH 02/24] fix: fix build mupdf --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc0f4e0..4649f15 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,14 +21,11 @@ jobs: yum groupinstall "Development Tools" -y yum install -y tar wget - - name: Download MuPDF + - name: Build MuPDF run: | wget https://mupdf.com/downloads/archive/mupdf-1.19.0-source.tar.xz tar -xf mupdf-1.19.0-source.tar.xz cd mupdf-1.19.0-source - - - name: Build MuPDF - run: | make build=release - name: Create the layer From 4a13a649451580d1e84a756099f077b7a8d31843 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:10:06 +0800 Subject: [PATCH 03/24] fix: install mesa-libGL-devel --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4649f15..44a4eab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: run: | yum update -y yum groupinstall "Development Tools" -y - yum install -y tar wget + yum install -y tar wget mesa-libGL-devel - name: Build MuPDF run: | From ed75b35ae37658ca5f7bba1e4438c3d8dcefc83f Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:17:32 +0800 Subject: [PATCH 04/24] feat: build only command line tool --- .github/workflows/build.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44a4eab..7d05bd6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,14 +19,15 @@ jobs: run: | yum update -y yum groupinstall "Development Tools" -y - yum install -y tar wget mesa-libGL-devel + yum install -y tar wget - name: Build MuPDF + # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html run: | - wget https://mupdf.com/downloads/archive/mupdf-1.19.0-source.tar.xz - tar -xf mupdf-1.19.0-source.tar.xz - cd mupdf-1.19.0-source - make build=release + wget https://mupdf.com/downloads/archive/mupdf-1.24.10-source.tar.xz + tar -xf mupdf-1.24.10-source.tar.xz + cd mupdf-1.24.10-source + make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install - name: Create the layer run: | From ae673b0c7989b0b5736e80cb9731458b24c879e8 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:19:10 +0800 Subject: [PATCH 05/24] fix: fix mupdf link --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d05bd6..fbc98af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,8 +24,8 @@ jobs: - name: Build MuPDF # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html run: | - wget https://mupdf.com/downloads/archive/mupdf-1.24.10-source.tar.xz - tar -xf mupdf-1.24.10-source.tar.xz + wget https://mupdf.com/downloads/archive/mupdf-1.24.10-source.tar.lz + tar -xf mupdf-1.24.10-source.tar.lz cd mupdf-1.24.10-source make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install From 846e03583d632206a7b93e36f4e8789289ca4ea5 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:20:55 +0800 Subject: [PATCH 06/24] fix: install lzip --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fbc98af..3d6c3f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: run: | yum update -y yum groupinstall "Development Tools" -y - yum install -y tar wget + yum install -y tar wget lzip - name: Build MuPDF # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html From 9b594e350f15a3f75ec2e46ffb09cd1896a34500 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:22:36 +0800 Subject: [PATCH 07/24] fix: tar -xv --lzip -f --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d6c3f3..b6a0b04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html run: | wget https://mupdf.com/downloads/archive/mupdf-1.24.10-source.tar.lz - tar -xf mupdf-1.24.10-source.tar.lz + tar -xv --lzip -f mupdf-1.24.10-source.tar.lz cd mupdf-1.24.10-source make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install From c9f7ba92a023774ae085ae9e1bfe8b5119b45ced Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:23:29 +0800 Subject: [PATCH 08/24] fix: download mupdf-1.24.10-source.tar.gz --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6a0b04..a2b503a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,8 +24,8 @@ jobs: - name: Build MuPDF # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html run: | - wget https://mupdf.com/downloads/archive/mupdf-1.24.10-source.tar.lz - tar -xv --lzip -f mupdf-1.24.10-source.tar.lz + wget https://mupdf.com/downloads/archive/mupdf-1.24.10-source.tar.gz + tar -xzf mupdf-1.24.10-source.tar.gz cd mupdf-1.24.10-source make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install From db212154cc185b06b1fe9947d2840faea4a4124d Mon Sep 17 00:00:00 2001 From: rwv <7891383+rwv@users.noreply.github.com> Date: Sat, 26 Oct 2024 01:31:05 +0800 Subject: [PATCH 09/24] feat: pack /usr/local/bin --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2b503a..8bb74bc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: - name: Create the layer run: | mkdir -p layer/bin - cp build/release/mutool layer/bin/ + cp /usr/local/bin/* layer/bin/ cd layer zip -r9 ../mutool-layer.zip . cd .. From 5bd76104e70216135fffe91e5a798352622635a2 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:47:47 +0800 Subject: [PATCH 10/24] fix: add Workaround for the nodejs20.x runtime --- .github/workflows/build.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8bb74bc..389b893 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: run: | yum update -y yum groupinstall "Development Tools" -y - yum install -y tar wget lzip + yum install -y tar wget lzip dnf - name: Build MuPDF # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html @@ -32,11 +32,18 @@ jobs: - name: Create the layer run: | mkdir -p layer/bin - cp /usr/local/bin/* layer/bin/ + cp /usr/local/bin/mutool layer/bin/ + cp /usr/local/bin/muraster layer/bin/ cd layer zip -r9 ../mutool-layer.zip . cd .. + - name: Workaround for the nodejs20.x runtime + run: | + sudo dnf -y install nodejs20 + mv /opt/actions-runner/externals/node20/bin/node /opt/actions-runner/externals/node20/bin/node-bak + ln -s /usr/bin/node-20 /opt/actions-runner/externals/node20/bin/node + - name: Upload the layer to the github artifact uses: actions/upload-artifact@v4 with: From 595c2fcb3290e485cd1c4c0dbc5853790e5bebf8 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:53:08 +0800 Subject: [PATCH 11/24] fix: copy shared lib as well --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 389b893..950793f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,9 @@ jobs: mkdir -p layer/bin cp /usr/local/bin/mutool layer/bin/ cp /usr/local/bin/muraster layer/bin/ + mkdir -p layer/lib + ldd /usr/local/bin/mutool | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib + ldd /usr/local/bin/muraster | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib cd layer zip -r9 ../mutool-layer.zip . cd .. From 3fe493f69f6e8a2bcfdcac27429ad4b317254391 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:53:35 +0800 Subject: [PATCH 12/24] fix: remove sudo for dnf --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 950793f..f449b80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,7 @@ jobs: - name: Workaround for the nodejs20.x runtime run: | - sudo dnf -y install nodejs20 + dnf -y install nodejs20 mv /opt/actions-runner/externals/node20/bin/node /opt/actions-runner/externals/node20/bin/node-bak ln -s /usr/bin/node-20 /opt/actions-runner/externals/node20/bin/node From cf8389fc717361caf1ee4e517e0b8a3c84560c15 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:54:39 +0800 Subject: [PATCH 13/24] fix: use amazonlinux:2023 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f449b80..3f8d522 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ concurrency: jobs: test: runs-on: ubuntu-latest - container: amazonlinux:2 + container: amazonlinux:2023 steps: - name: Install the necessary tools run: | From 0176f0ba2da061d5bdcb6dcd7965b2fc7c0e17a0 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 01:55:03 +0800 Subject: [PATCH 14/24] fix: remove lzip yum install --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f8d522..bdd1d5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: run: | yum update -y yum groupinstall "Development Tools" -y - yum install -y tar wget lzip dnf + yum install -y tar wget dnf - name: Build MuPDF # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html From 7c2053f91cd80810206c2a085b648adf0a06c080 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 02:00:32 +0800 Subject: [PATCH 15/24] fix: remove upload artifact for now --- .github/workflows/build.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdd1d5e..4c2645d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,18 +41,6 @@ jobs: zip -r9 ../mutool-layer.zip . cd .. - - name: Workaround for the nodejs20.x runtime - run: | - dnf -y install nodejs20 - mv /opt/actions-runner/externals/node20/bin/node /opt/actions-runner/externals/node20/bin/node-bak - ln -s /usr/bin/node-20 /opt/actions-runner/externals/node20/bin/node - - - name: Upload the layer to the github artifact - uses: actions/upload-artifact@v4 - with: - name: mutool-layer - path: mutool-layer.zip - - name: Login to AWS run: | aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} From 6ae546b1ce8b21b7aed86013685a05df84f54fe3 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 02:05:19 +0800 Subject: [PATCH 16/24] fix: install awscli --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c2645d..4d7c7e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: run: | yum update -y yum groupinstall "Development Tools" -y - yum install -y tar wget dnf + yum install -y tar wget dnf awscli - name: Build MuPDF # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html From 240bf6284af1f6ca5e9d67dd2d166b3cc05360ec Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 02:18:20 +0800 Subject: [PATCH 17/24] fix: uploadd to s3 --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d7c7e7..7c6234b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,10 +47,14 @@ jobs: aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws configure set region ${{ secrets.AWS_REGION }} + - name: Upload to S3 + run: | + aws s3 cp mutool-layer.zip s3://mutool-layer/mutool-layer.zip + - name: Deploy the layer to the artifact registry run: | aws lambda publish-layer-version \ --layer-name mutool-layer \ - --zip-file fileb://mutool-layer.zip \ + --content S3Bucket=mutool-layer,S3Key=mutool-layer.zip \ --compatible-runtimes nodejs20.x --region ${{ secrets.AWS_REGION }} From aeb00993c1205c2f1134ef98a6a97eb8a0502090 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 02:23:45 +0800 Subject: [PATCH 18/24] fix: remove useless command --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c6234b..05930d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,5 @@ jobs: - name: Deploy the layer to the artifact registry run: | aws lambda publish-layer-version \ - --layer-name mutool-layer \ - --content S3Bucket=mutool-layer,S3Key=mutool-layer.zip \ - --compatible-runtimes nodejs20.x - --region ${{ secrets.AWS_REGION }} + --layer-name mutool \ + --content S3Bucket=mutool-layer,S3Key=mutool-layer.zip From a1eccef3ab2b167d1192faf34c4bc562621f748f Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 02:25:31 +0800 Subject: [PATCH 19/24] docs: add description --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05930d6..735992e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,4 +55,5 @@ jobs: run: | aws lambda publish-layer-version \ --layer-name mutool \ - --content S3Bucket=mutool-layer,S3Key=mutool-layer.zip + --content S3Bucket=mutool-layer,S3Key=mutool-layer.zip \ + --description "MuPDF CLI tools v1.24.10" From 6f20057f993c0d1b209f520499ebc03916307dd4 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 03:03:07 +0800 Subject: [PATCH 20/24] refactor: use secret S3_BUCKET --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 735992e..f056190 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,11 +49,11 @@ jobs: - name: Upload to S3 run: | - aws s3 cp mutool-layer.zip s3://mutool-layer/mutool-layer.zip + aws s3 cp mutool-layer.zip s3://${{ secrets.S3_BUCKET }}/mutool-layer.zip - name: Deploy the layer to the artifact registry run: | aws lambda publish-layer-version \ --layer-name mutool \ - --content S3Bucket=mutool-layer,S3Key=mutool-layer.zip \ + --content S3Bucket=${{ secrets.S3_BUCKET }},S3Key=mutool-layer.zip \ --description "MuPDF CLI tools v1.24.10" From 23525dd9c8822d19ea4f8bfe3f2b4e58136ff492 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 03:03:58 +0800 Subject: [PATCH 21/24] refactor: use env.MUPDF_VERSION in workflow --- .github/workflows/build.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f056190..ad2d2fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +env: + MUPDF_VERSION: 1.24.10 + jobs: test: runs-on: ubuntu-latest @@ -24,9 +27,9 @@ jobs: - name: Build MuPDF # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html run: | - wget https://mupdf.com/downloads/archive/mupdf-1.24.10-source.tar.gz - tar -xzf mupdf-1.24.10-source.tar.gz - cd mupdf-1.24.10-source + wget https://mupdf.com/downloads/archive/mupdf-${{ env.MUPDF_VERSION }}-source.tar.gz + tar -xzf mupdf-${{ env.MUPDF_VERSION }}-source.tar.gz + cd mupdf-${{ env.MUPDF_VERSION }}-source make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install - name: Create the layer @@ -56,4 +59,4 @@ jobs: aws lambda publish-layer-version \ --layer-name mutool \ --content S3Bucket=${{ secrets.S3_BUCKET }},S3Key=mutool-layer.zip \ - --description "MuPDF CLI tools v1.24.10" + --description "MuPDF CLI tools v${{ env.MUPDF_VERSION }}" From 0fd9ed820897ecffd650bfd637341d06cb4201dc Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 03:06:41 +0800 Subject: [PATCH 22/24] ci: only publish when release --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad2d2fc..9f693af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,8 @@ name: Build on: push: + branches: + - main pull_request: release: types: [published] @@ -45,16 +47,19 @@ jobs: cd .. - name: Login to AWS + if: github.event_name == 'release' run: | aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws configure set region ${{ secrets.AWS_REGION }} - name: Upload to S3 + if: github.event_name == 'release' run: | aws s3 cp mutool-layer.zip s3://${{ secrets.S3_BUCKET }}/mutool-layer.zip - name: Deploy the layer to the artifact registry + if: github.event_name == 'release' run: | aws lambda publish-layer-version \ --layer-name mutool \ From 6ff1261b3534d6375c86bc8fda11408394ed89c3 Mon Sep 17 00:00:00 2001 From: Seedgou Date: Sat, 26 Oct 2024 03:08:54 +0800 Subject: [PATCH 23/24] ci: change layer name to mupdf --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f693af..eabf2e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,7 @@ jobs: ldd /usr/local/bin/mutool | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib ldd /usr/local/bin/muraster | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib cd layer - zip -r9 ../mutool-layer.zip . + zip -r9 ../mupdf-layer.zip . cd .. - name: Login to AWS @@ -56,12 +56,12 @@ jobs: - name: Upload to S3 if: github.event_name == 'release' run: | - aws s3 cp mutool-layer.zip s3://${{ secrets.S3_BUCKET }}/mutool-layer.zip + aws s3 cp mupdf-layer.zip s3://${{ secrets.S3_BUCKET }}/mupdf-layer.zip - name: Deploy the layer to the artifact registry if: github.event_name == 'release' run: | aws lambda publish-layer-version \ - --layer-name mutool \ - --content S3Bucket=${{ secrets.S3_BUCKET }},S3Key=mutool-layer.zip \ + --layer-name mupdf \ + --content S3Bucket=${{ secrets.S3_BUCKET }},S3Key=mupdf-layer.zip \ --description "MuPDF CLI tools v${{ env.MUPDF_VERSION }}" From 9205a92d602daa6189c3d889ddba4cb4627dd87b Mon Sep 17 00:00:00 2001 From: Seedgou Date: Tue, 29 Oct 2024 14:02:38 +0800 Subject: [PATCH 24/24] docs: add README --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/README.md b/README.md index c42f468..987c02b 100644 --- a/README.md +++ b/README.md @@ -1 +1,57 @@ # mupdf-aws-lambda-layer + +[![Build](https://github.com/rwv/mupdf-aws-lambda-layer/actions/workflows/build.yml/badge.svg)](https://github.com/rwv/mupdf-aws-lambda-layer/actions/workflows/build.yml) + +An AWS Lambda Layer containing MuPDF CLI tools (mutool and muraster) built for Amazon Linux 2023. + +## Overview + +This project provides a Lambda Layer that packages MuPDF command-line tools, making them available for use in AWS Lambda functions. The layer is built using Amazon Linux 2023 to ensure compatibility with Lambda's runtime environment. + +## Version + +Current MuPDF version: [1.24.10](https://mupdf.com/releases/history) + +## Contents + +The layer includes: +- `bin/mutool` - An all purpose tool for dealing with PDF files +- `bin/muraster` - Can be used to convert PDF pages to raster images +- `lib/*` - All required shared libraries + +## Usage + +### Manual Layer Usage + +1. Download the layer ZIP from the [latest release](https://github.com/rwv/mupdf-aws-lambda-layer/releases/latest) +2. Create a new Lambda Layer in your AWS account +3. Upload the ZIP file +4. Attach the layer to your Lambda function + +### Automated Layer Deployment + +The layer is automatically published to AWS Lambda's layer registry on each release. You can fork this repository and add the following repository secrets to enable automated deployments: + +- `AWS_ACCESS_KEY_ID`: Your AWS access key ID +- `AWS_SECRET_ACCESS_KEY`: Your AWS secret access key +- `AWS_REGION`: The AWS region to deploy to +- `S3_BUCKET`: The S3 bucket name for storing the layer ZIP file + +## Building + +The layer is automatically built using GitHub Actions. The workflow: +1. Sets up an Amazon Linux 2023 container +2. Builds MuPDF from source +3. Packages the binaries and dependencies +4. Creates a ZIP file +5. Publishes to S3 and Lambda Layer registry (on release only) + +To build locally, you can follow the steps in the GitHub Actions workflow file. + +## License + +This project is provided under the same license as MuPDF. See [MuPDF's license](https://mupdf.com/#licensing) for details. + +## Contributing + +Contributions are welcome! Please feel free to submit a Pull Request.