# SPDX-FileCopyrightText: Stone Tickle <lattis@mochiro.moe>
# SPDX-License-Identifier: GPL-3.0-only

image: alpine/3.17
secrets:
  - 2fe5fef6-db89-4410-8147-07e314589d18
  - 18083346-dfba-4050-bc05-413561f99228
repositories:
  edge_testing: >
    http://dl-cdn.alpinelinux.org/alpine/edge/testing
    https://muon.build/nothing
    ../../../dev/null
  community: >
    http://dl-cdn.alpinelinux.org/alpine/v3.17/community # must be kept in sync with the image's alpine version
    https://muon.build/nothing
    ../../../dev/null
packages:
  - curl-dev
  - libarchive-dev
  - pkgconf-dev

  - python3 # for project tests, meson-reference.3, and parts of the website
  - linux-headers # used in a few project tests
  - py3-yaml # for meson-reference.3
  - scdoc # for meson.build.5 and muon.1
  - mandoc # for html man pages
  - reuse # for licensing compliance

  # alternative c compilers
  - clang
  - tcc
  - tcc-libs-static # tcc 0.9.27_git20220323-r1 is broken without this

  # for static builds
  - acl-static
  - brotli-static
  - bzip2-static
  - curl-static
  - expat-static
  - libarchive-static
  - lz4-static
  - nghttp2-static
  - openssl-libs-static
  - xz-static
  - zlib-static
  - zstd-dev

  # for releases
  - rsync
sources:
  - https://git.sr.ht/~lattis/muon
environment:
  PKG_CONFIG_PATH: /usr/lib/pkgconfig
tasks:
  - reuse: |
      cd muon
      reuse lint
  - push_to_gh_mirror: |
      cd muon
      tools/ci/push_to_gh_mirror.sh
  - kickoff_custom_ci: |
      cd muon
      if [ -d ~/.ssh ]; then
        tools/ci/solaris11.sh submit
      fi
  - build_gcc: |
      # In order to fetch the meson-docs wrap, we have to build muon twice,
      # once to bootstrap, and then again when we have libcurl
      cd muon
      OPTS="-Dlibpkgconf=enabled -Dlibarchive=enabled -Dlibcurl=enabled -Dbuildtype=release -Dstatic=true -Dwebsite=true -Dwerror=true"
      CC=gcc tools/ci/bootstrap.sh build $OPTS
      build/muon setup $OPTS build
      build/muon -C build samu
  - build_tcc: |
      cd muon
      CC=tcc tools/ci/bootstrap.sh build-tcc
  - test_gcc: |
      cd muon/build
      CC=gcc ./muon test -d dots
  - test_clang: |
      cd muon/build
      CC=clang ./muon test -d dots
  - build_small: |
      cd muon
      CC=gcc build/muon setup \
        -Dbuildtype=minsize \
        -Dstatic=true \
        -Dlibcurl=disabled \
        -Dlibarchive=disabled \
        build-small
      build/muon -C build-small samu
  - release: |
      cd muon
      ver="$(cat build/version.txt)"
      tools/ci/prepare_release_docs.sh build
      tools/ci/prepare_binary.sh build "$ver-amd64-linux-static"
      tools/ci/prepare_binary.sh build-small "${ver}-amd64-linux-static-small"
      tools/ci/prepare_tarball.sh "muon-${ver}"
      tools/ci/deploy.sh / -r --delete build/doc/website
      tools/ci/deploy.sh "/releases/${ver}" -r --delete build/doc/docs
      tools/ci/deploy.sh "/releases/${ver}" \
        "build/muon-${ver}-amd64-linux-static" \
        "build/muon-${ver}-amd64-linux-static.md5" \
        "build-small/muon-${ver}-amd64-linux-static-small" \
        "build-small/muon-${ver}-amd64-linux-static-small.md5" \
        "muon-${ver}.tar.gz"
