|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'master' |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - 'master' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + # Each nginx version to build against |
| 17 | + nginx-version: ['1.20.2', '1.22.1', '1.24.0', '1.25.1'] |
| 18 | + # The following versions of libjwt are compatible: |
| 19 | + # * v1.0 - v1.12.0 |
| 20 | + # * v1.12.1 - v1.14.0 |
| 21 | + # * v1.15.0+ |
| 22 | + # At the time of writing this: |
| 23 | + # * Debian and Ubuntu's repos have v1.10.2 |
| 24 | + # * EPEL has v1.12.1 |
| 25 | + # This compilles against each version prior to a breaking change and the latest release |
| 26 | + libjwt-version: ['1.12.0', '1.14.0', '1.15.3'] |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v3 |
| 31 | + with: |
| 32 | + path: 'ngx-http-auth-jwt-module' |
| 33 | + |
| 34 | + - name: Download jansson |
| 35 | + uses: actions/checkout@v3 |
| 36 | + with: |
| 37 | + repository: 'akheron/jansson' |
| 38 | + ref: 'v2.14' |
| 39 | + path: 'jansson' |
| 40 | + |
| 41 | + - name: Build jansson |
| 42 | + working-directory: ./jansson |
| 43 | + run: | |
| 44 | + cmake . -DJANSSON_BUILD_SHARED_LIBS=1 -DJANSSON_BUILD_DOCS=OFF && \ |
| 45 | + make && \ |
| 46 | + make check && \ |
| 47 | + sudo make install |
| 48 | + |
| 49 | + - name: Download libjwt |
| 50 | + uses: actions/checkout@v3 |
| 51 | + with: |
| 52 | + repository: 'benmcollins/libjwt' |
| 53 | + ref: 'v${{matrix.libjwt-version}}' |
| 54 | + path: 'libjwt' |
| 55 | + |
| 56 | + - name: Build libjwt |
| 57 | + working-directory: ./libjwt |
| 58 | + run: | |
| 59 | + autoreconf -i && \ |
| 60 | + ./configure && \ |
| 61 | + make all && \ |
| 62 | + sudo make install |
| 63 | +
|
| 64 | + - name: Download NGINX |
| 65 | + run: | |
| 66 | + mkdir nginx |
| 67 | + curl -O http://nginx.org/download/nginx-${{matrix.nginx-version}}.tar.gz |
| 68 | + tar -xzf nginx-${{matrix.nginx-version}}.tar.gz --strip-components 1 -C nginx |
| 69 | + |
| 70 | + - name: Run configure |
| 71 | + working-directory: ./nginx |
| 72 | + run: | |
| 73 | + BUILD_FLAGS='' |
| 74 | + MAJ=$(echo ${{matrix.nginx-version}} | cut -f1 -d.) |
| 75 | + MIN=$(echo ${{matrix.nginx-version}} | cut -f2 -d.) |
| 76 | + REV=$(echo ${{matrix.nginx-version}} | cut -f3 -d.) |
| 77 | + if [ "${MAJ}" -gt 1 ] || [ "${MAJ}" -eq 1 -a "${MIN}" -ge 23 ]; then |
| 78 | + BUILD_FLAGS="${BUILD_FLAGS} --with-cc-opt='-DNGX_LINKED_LIST_COOKIES=1'" |
| 79 | + fi |
| 80 | + ./configure --with-compat --add-dynamic-module=../ngx-http-auth-jwt-module ${BUILD_FLAGS} |
| 81 | + |
| 82 | + - name: Run make |
| 83 | + working-directory: ./nginx |
| 84 | + run: make modules |
| 85 | + |
| 86 | + - name: Create release archive |
| 87 | + run: | |
| 88 | + cp ./nginx/objs/ngx_http_auth_jwt_module.so ./ |
| 89 | + tar czf ngx_http_auth_jwt_module_${{github.ref_name}}_libjwt_${{matrix.libjwt-version}}_nginx_${{matrix.nginx-version}}.tgz ngx_http_auth_jwt_module.so |
| 90 | +
|
| 91 | + - name: Upload build artifact |
| 92 | + uses: actions/upload-artifact@v3 |
| 93 | + with: |
| 94 | + if-no-files-found: error |
| 95 | + name: ngx_http_auth_jwt_module_${{github.ref_name}}_libjwt_${{matrix.libjwt-version}}_nginx_${{matrix.nginx-version}}.tgz |
| 96 | + path: ngx_http_auth_jwt_module_${{github.ref_name}}_libjwt_${{matrix.libjwt-version}}_nginx_${{matrix.nginx-version}}.tgz |
| 97 | + |
| 98 | + update_releases_page: |
| 99 | + name: Upload builds to Releases |
| 100 | + if: github.event_name != 'pull_request' |
| 101 | + needs: |
| 102 | + - build |
| 103 | + runs-on: ubuntu-latest |
| 104 | + permissions: |
| 105 | + contents: write |
| 106 | + steps: |
| 107 | + - name: Set up variables |
| 108 | + id: vars |
| 109 | + run: | |
| 110 | + echo "date_now=$(date --rfc-3339=seconds)" >> "${GITHUB_OUTPUT}" |
| 111 | + |
| 112 | + - name: Download build artifacts from previous jobs |
| 113 | + uses: actions/download-artifact@v3 |
| 114 | + with: |
| 115 | + path: artifacts |
| 116 | + |
| 117 | + - name: Upload builds to Releases |
| 118 | + uses: ncipollo/release-action@v1 |
| 119 | + with: |
| 120 | + allowUpdates: true |
| 121 | + artifactErrorsFailBuild: true |
| 122 | + artifacts: artifacts/*/* |
| 123 | + body: | |
| 124 | + > [!WARNING] |
| 125 | + > This is an automatically generated pre-release version of the module, which includes the latest master branch changes. |
| 126 | + > Please report any bugs you find to the issue tracker. |
| 127 | +
|
| 128 | + - Build Date: `${{ steps.vars.outputs.date_now }}` |
| 129 | + - Commit: ${{ github.sha }} |
| 130 | + name: 'Development build: ${{ github.ref_name }}@${{ github.sha }}' |
| 131 | + prerelease: true |
| 132 | + removeArtifacts: true |
| 133 | + tag: dev-build |
0 commit comments