Skip to content
Myr

ci.yml

This file

Path

.github/workflows/ci.yml

431 lines · 12.6 KiB · YAML

Last changed by

build(deps): bump actions/checkout from 6 to 7 in the official-actions group (#3565)dependabot[bot]before adoption34f7186

History of this file

Take it

1name: CI2on:3  push:4    branches:5      - master6    tags:7      - "jq-*"8  pull_request:910jobs:11  linux:12    strategy:13      fail-fast: false14      matrix:15        arch:16          - amd6417          - arm6418          - armel19          - armhf20          - i38621          - mips22          - mips6423          - mips64el24          - mips64r625          - mips64r6el26          - mipsel27          - mipsr628          - mipsr6el29          - powerpc30          - ppc64el31          - riscv6432          - s390x33        include:34          - arch: amd6435            CC: x86_64-linux-gnu36          - arch: arm6437            CC: aarch64-linux-gnu38          - arch: armel39            CC: arm-linux-gnueabi40          - arch: armhf41            CC: arm-linux-gnueabihf42          - arch: i38643            CC: i686-linux-gnu44          - arch: mips45            CC: mips-linux-gnu46          - arch: mips6447            CC: mips64-linux-gnuabi6448          - arch: mips64el49            CC: mips64el-linux-gnuabi6450          - arch: mips64r651            CC: mipsisa64r6-linux-gnuabi6452          - arch: mips64r6el53            CC: mipsisa64r6el-linux-gnuabi6454          - arch: mipsel55            CC: mipsel-linux-gnu56          - arch: mipsr657            CC: mipsisa32r6-linux-gnu58          - arch: mipsr6el59            CC: mipsisa32r6el-linux-gnu60          - arch: powerpc61            CC: powerpc-linux-gnu62          - arch: ppc64el63            CC: powerpc64le-linux-gnu64          - arch: riscv6465            CC: riscv64-linux-gnu66          - arch: s390x67            CC: s390x-linux-gnu68    runs-on: ${{ matrix.arch == 'i386' && 'ubuntu-22.04' || 'ubuntu-24.04' }}69    env:70      AR: ${{ matrix.CC }}-ar71      CHOST: ${{ matrix.CC }}72      CC: ${{ matrix.CC }}-gcc73      CPP: ${{ matrix.CC }}-cpp74      LDFLAGS: -s75      SUFFIX: linux-${{ matrix.arch }}76    steps:77      - name: Clone repository78        uses: actions/checkout@v779        with:80          submodules: true81      - name: Install packages82        run: |83          sudo apt-get update84          sudo apt-get install -y automake autoconf libtool crossbuild-essential-${{ matrix.arch }}85      - name: Build86        run: |87          autoreconf -i88          ./configure \89            --host=${{ matrix.CC }} \90            --disable-docs \91            --with-oniguruma=builtin \92            --enable-static \93            --enable-all-static \94            CFLAGS="-O2 -pthread -fstack-protector-all"95          make -j"$(nproc)"96          file ./jq97          cp ./jq jq-${{ env.SUFFIX }}98      - name: Test99        # Only run tests for amd64 matching the CI machine arch100        if: ${{ matrix.arch == 'amd64' }}101        run: |102          make check VERBOSE=yes103          git diff --exit-code104      - name: Upload Test Logs105        if: ${{ failure() }}106        uses: actions/upload-artifact@v7107        with:108          name: test-logs-${{ env.SUFFIX }}109          retention-days: 7110          path: |111            test-suite.log112            tests/*.log113      - name: Upload artifacts114        uses: actions/upload-artifact@v7115        with:116          name: jq-${{ env.SUFFIX }}117          path: jq-${{ env.SUFFIX }}118          if-no-files-found: error119          retention-days: 7120121  macos:122    strategy:123      fail-fast: false124      matrix:125        arch:126          - amd64127          - arm64128        include:129          - arch: amd64130            target: x86_64-apple-darwin131          - arch: arm64132            target: arm64-apple-darwin133    runs-on: macos-14134    env:135      LDFLAGS: -dead_strip136      SUFFIX: macos-${{ matrix.arch }}137    steps:138      - name: Clone repository139        uses: actions/checkout@v7140        with:141          submodules: true142      - name: Install packages143        run: |144          # brew update sometimes fails with "Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!"145          brew update || brew update-reset146          brew install autoconf automake libtool147      - name: Set CC148        run: |149          echo "CC=clang -target ${{ matrix.target }}$(uname -r)" >> "$GITHUB_ENV"150      - name: Build151        run: |152          autoreconf -i153          ./configure \154            --host="${{ matrix.target }}$(uname -r)" \155            --disable-docs \156            --with-oniguruma=builtin \157            --disable-shared \158            --enable-static \159            --enable-all-static \160            CFLAGS="-O2 -pthread -fstack-protector-all"161          make -j"$(sysctl -n hw.logicalcpu)"162          strip ./jq163          file ./jq164          cp ./jq jq-${{ env.SUFFIX }}165      - name: Test166        run: |167          make check VERBOSE=yes168          git diff --exit-code169      - name: Upload Test Logs170        if: ${{ failure() }}171        uses: actions/upload-artifact@v7172        with:173          name: test-logs-${{ env.SUFFIX }}174          retention-days: 7175          path: |176            test-suite.log177            tests/*.log178      - name: Upload artifacts179        uses: actions/upload-artifact@v7180        with:181          name: jq-${{ env.SUFFIX }}182          path: jq-${{ env.SUFFIX }}183          if-no-files-found: error184          retention-days: 7185186  windows:187    strategy:188      fail-fast: false189      matrix:190        arch:191          - amd64192          - i386193          - arm64194        include:195          - arch: amd64196            msystem: UCRT64197            os: windows-2022198          - arch: i386199            msystem: MINGW32200            os: windows-2022201          - arch: arm64202            msystem: CLANGARM64203            os: windows-11-arm204    runs-on: ${{ matrix.os }}205    env:206      LDFLAGS: -s207      SUFFIX: windows-${{ matrix.arch }}208    defaults:209      run:210        shell: msys2 {0}211    steps:212      - name: Prepare git config213        run: git config --system core.autocrlf false214        shell: bash215      - name: Clone repository216        uses: actions/checkout@v7217        with:218          submodules: true219      - uses: msys2/setup-msys2@v2220        with:221          update: true222          msystem: ${{ matrix.msystem }}223          install: >-224            base-devel225            git226            autoconf227            automake228            libtool229          pacboy: >-230            toolchain:p231      - name: Build232        run: |233          autoreconf -i234          ./configure \235            --disable-docs \236            --with-oniguruma=builtin \237            --disable-shared \238            --enable-static \239            --enable-all-static \240            CFLAGS="-O2 -pthread -fstack-protector-all -Wl,--stack,8388608"241          make -j$(nproc)242          file ./jq.exe243          cp ./jq.exe jq-${{ env.SUFFIX }}.exe244      - name: Test245        run: |246          make check VERBOSE=yes247          git diff --exit-code248      - name: Upload Test Logs249        if: ${{ failure() }}250        uses: actions/upload-artifact@v7251        with:252          name: test-logs-${{ env.SUFFIX }}253          retention-days: 7254          path: |255            test-suite.log256            tests/*.log257      - name: Upload artifacts258        uses: actions/upload-artifact@v7259        with:260          name: jq-${{ env.SUFFIX }}261          path: jq-${{ env.SUFFIX }}.exe262          if-no-files-found: error263          retention-days: 7264265  dist:266    runs-on: ubuntu-latest267    steps:268      - name: Clone repository269        uses: actions/checkout@v7270        with:271          submodules: true272      - name: Install packages273        run: |274          sudo apt-get update -qq275          sudo apt-get install -y automake autoconf276      - name: Create dist277        run: |278          autoreconf -i279          ./configure \280            --disable-docs \281            --with-oniguruma=builtin282          make distcheck283          make dist dist-zip284          git diff --exit-code285      - name: Upload artifacts286        uses: actions/upload-artifact@v7287        with:288          name: jq-dist289          if-no-files-found: error290          retention-days: 7291          path: |292            jq-*.tar.gz293            jq-*.zip294295  docker:296    runs-on: ubuntu-latest297    permissions:298      id-token: write299      contents: read300      attestations: write301      artifact-metadata: write302      packages: write303    needs: linux304    steps:305      - name: Clone repository306        uses: actions/checkout@v7307      - name: Download executables308        uses: actions/download-artifact@v8309        with:310          pattern: jq-linux-*311          merge-multiple: true312      - name: Move executables313        run: |314          mkdir -p linux/{386,amd64,arm64,arm/v7,mips64le,ppc64le,riscv64,s390x}315          chmod +x jq-linux-*316          mv jq-linux-i386 linux/386/jq317          mv jq-linux-amd64 linux/amd64/jq318          mv jq-linux-arm64 linux/arm64/jq319          mv jq-linux-armhf linux/arm/v7/jq320          mv jq-linux-mips64el linux/mips64le/jq321          mv jq-linux-ppc64el linux/ppc64le/jq322          mv jq-linux-riscv64 linux/riscv64/jq323          mv jq-linux-s390x linux/s390x/jq324      - name: Create Dockerfile325        run: |326          cat <<'EOF' >Dockerfile327          FROM scratch328          ARG TARGETPLATFORM329          COPY AUTHORS COPYING $TARGETPLATFORM/jq /330          RUN ["/jq", "--version"]331          ENTRYPOINT ["/jq"]332          EOF333      - name: Docker metadata334        uses: docker/metadata-action@v6335        id: metadata336        with:337          images: ghcr.io/${{ github.repository }}338          tags: >339            ${{ startsWith(github.ref, 'refs/tags/jq-')340            && format('type=match,pattern=jq-(.*),group=1,value={0}', github.ref_name)341            || 'type=sha,format=long' }}342      - name: Set up QEMU343        uses: docker/setup-qemu-action@v4344      - name: Set up Docker Buildx345        uses: docker/setup-buildx-action@v4346      - name: Login to GitHub Container Registry347        uses: docker/login-action@v4348        with:349          registry: ghcr.io350          username: ${{ github.repository_owner }}351          password: ${{ secrets.GITHUB_TOKEN }}352      - name: Build and release Docker image353        uses: docker/build-push-action@v7354        id: build-push355        with:356          context: .357          push: ${{ startsWith(github.ref, 'refs/tags/jq-') }}358          provenance: false359          platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/mips64le,linux/ppc64le,linux/riscv64,linux/s390x360          tags: ${{ steps.metadata.outputs.tags }}361          labels: ${{ steps.metadata.outputs.labels }}362      - name: Generate signed attestations363        if: startsWith(github.ref, 'refs/tags/jq-')364        uses: actions/attest@v4365        with:366          subject-name: ghcr.io/${{ github.repository }}367          subject-digest: ${{ steps.build-push.outputs.digest }}368          push-to-registry: true369370  release:371    runs-on: ubuntu-latest372    permissions:373      contents: write374      id-token: write375      attestations: write376      artifact-metadata: write377      pull-requests: write378    environment: release379    needs: [linux, macos, windows, dist, docker]380    if: startsWith(github.ref, 'refs/tags/jq-')381    steps:382      - name: Clone repository383        uses: actions/checkout@v7384      - name: Download artifacts385        uses: actions/download-artifact@v8386        with:387          pattern: jq-*388          merge-multiple: true389      - name: Prepare release artifacts390        run: |391          cp jq-linux-amd64 jq-linux64392          cp jq-macos-amd64 jq-osx-amd64393          cp jq-windows-amd64.exe jq-win64.exe394      - name: Generate signed attestations395        id: attest396        uses: actions/attest@v4397        with:398          subject-path: jq-*399      - name: Upload release400        env:401          TAG_NAME: ${{ github.ref_name }}402          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}403        run: |404          mv "${{ steps.attest.outputs.bundle-path }}" jq-attestation.json405          sha256sum jq-* > sha256sum.txt406          gh release create "$TAG_NAME" --draft --title "jq ${TAG_NAME#jq-}" --generate-notes407          gh release upload "$TAG_NAME" --clobber jq-* sha256sum.txt408      - name: Import GPG key409        uses: crazy-max/ghaction-import-gpg@v7410        with:411          gpg_private_key: ${{ secrets.JQ_RELEASE_GPG_PRIVATE_KEY }}412          passphrase: ${{ secrets.JQ_RELEASE_GPG_PASSPHRASE }}413      - name: Update signatures414        env:415          TAG_NAME: ${{ github.ref_name }}416          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}417        run: |418          sig_dir="sig/v${TAG_NAME#jq-}"419          mkdir -p "$sig_dir"420          mv sha256sum.txt "$sig_dir"421          for file in jq-*; do422            gpg --detach-sign --armor --batch --output "${sig_dir}/${file#*/}.asc" "$file"423          done424          git add sig425          git config user.name 'github-actions[bot]'426          git config user.email 'github-actions[bot]@users.noreply.github.com'427          title="Update signatures of ${TAG_NAME#jq-}"428          git commit -m "$title"429          branch="update-signatures-${TAG_NAME#jq-}"430          git push origin "HEAD:refs/heads/$branch"431          gh pr create --title "$title" --body "" --head "$branch"