|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +env: |
| 16 | + MUPDF_VERSION: 1.24.10 |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + container: amazonlinux:2023 |
| 22 | + steps: |
| 23 | + - name: Install the necessary tools |
| 24 | + run: | |
| 25 | + yum update -y |
| 26 | + yum groupinstall "Development Tools" -y |
| 27 | + yum install -y tar wget dnf awscli |
| 28 | +
|
| 29 | + - name: Build MuPDF |
| 30 | + # https://mupdf.readthedocs.io/en/latest/quick-start-guide.html |
| 31 | + run: | |
| 32 | + wget https://mupdf.com/downloads/archive/mupdf-${{ env.MUPDF_VERSION }}-source.tar.gz |
| 33 | + tar -xzf mupdf-${{ env.MUPDF_VERSION }}-source.tar.gz |
| 34 | + cd mupdf-${{ env.MUPDF_VERSION }}-source |
| 35 | + make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install |
| 36 | +
|
| 37 | + - name: Create the layer |
| 38 | + run: | |
| 39 | + mkdir -p layer/bin |
| 40 | + cp /usr/local/bin/mutool layer/bin/ |
| 41 | + cp /usr/local/bin/muraster layer/bin/ |
| 42 | + mkdir -p layer/lib |
| 43 | + ldd /usr/local/bin/mutool | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib |
| 44 | + ldd /usr/local/bin/muraster | grep '=>' | awk '{print $3}' | xargs -I '{}' cp -v '{}' layer/lib |
| 45 | + cd layer |
| 46 | + zip -r9 ../mupdf-layer.zip . |
| 47 | + cd .. |
| 48 | +
|
| 49 | + - name: Login to AWS |
| 50 | + if: github.event_name == 'release' |
| 51 | + run: | |
| 52 | + aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 53 | + aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 54 | + aws configure set region ${{ secrets.AWS_REGION }} |
| 55 | +
|
| 56 | + - name: Upload to S3 |
| 57 | + if: github.event_name == 'release' |
| 58 | + run: | |
| 59 | + aws s3 cp mupdf-layer.zip s3://${{ secrets.S3_BUCKET }}/mupdf-layer.zip |
| 60 | +
|
| 61 | + - name: Deploy the layer to the artifact registry |
| 62 | + if: github.event_name == 'release' |
| 63 | + run: | |
| 64 | + aws lambda publish-layer-version \ |
| 65 | + --layer-name mupdf \ |
| 66 | + --content S3Bucket=${{ secrets.S3_BUCKET }},S3Key=mupdf-layer.zip \ |
| 67 | + --description "MuPDF CLI tools v${{ env.MUPDF_VERSION }}" |
0 commit comments