# @generated by generate-release-yml.rs
---
name: release
"on":
  push:
    tags:
      - v*

permissions:
  contents: write  #  to create a release

jobs:
  prepare:
    runs-on: ubuntu-latest
    outputs:
      release: "${{ steps.info.outputs.name }}"
      upload_url: "${{ steps.create_release.outputs.upload_url }}"
    steps:
      - name: Prepare release info
        id: info
        env:
          TAG: "${{ github.ref }}"
        run: "python -c \"print('::set-output name=name::' + '$TAG'.lstrip('refs/tags/'))\""
      - name: Create release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        with:
          tag_name: "${{ github.ref }}"
          release_name: "${{ github.ref }}"
  docker-ubuntu-20:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: "${{ github.repository_owner }}"
          password: "${{ secrets.GITHUB_TOKEN }}"
      - name: Build and push Docker image
        uses: docker/build-push-action@v3
        with:
          context: "."
          build-args: UBUNTU_VERSION=20.04
          file: watchman/build/package/ubuntu-env/Dockerfile
          push: true
          tags: "${{ format('ghcr.io/{0}/watchman-build-env-ubuntu-20:latest', github.repository) }}"
  docker-ubuntu-22:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: "${{ github.repository_owner }}"
          password: "${{ secrets.GITHUB_TOKEN }}"
      - name: Build and push Docker image
        uses: docker/build-push-action@v3
        with:
          context: "."
          build-args: UBUNTU_VERSION=22.04
          file: watchman/build/package/ubuntu-env/Dockerfile
          push: true
          tags: "${{ format('ghcr.io/{0}/watchman-build-env-ubuntu-22:latest', github.repository) }}"
  docker-fedora-36:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: "${{ github.repository_owner }}"
          password: "${{ secrets.GITHUB_TOKEN }}"
      - name: Build and push Docker image
        uses: docker/build-push-action@v3
        with:
          context: "."
          build-args: FEDORA_VERSION=36
          file: watchman/build/package/fedora-env/Dockerfile
          push: true
          tags: "${{ format('ghcr.io/{0}/watchman-build-env-fedora-36:latest', github.repository) }}"
  docker-fedora-37:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: "${{ github.repository_owner }}"
          password: "${{ secrets.GITHUB_TOKEN }}"
      - name: Build and push Docker image
        uses: docker/build-push-action@v3
        with:
          context: "."
          build-args: FEDORA_VERSION=37
          file: watchman/build/package/fedora-env/Dockerfile
          push: true
          tags: "${{ format('ghcr.io/{0}/watchman-build-env-fedora-37:latest', github.repository) }}"
  docker-fedora-38:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: "${{ github.repository_owner }}"
          password: "${{ secrets.GITHUB_TOKEN }}"
      - name: Build and push Docker image
        uses: docker/build-push-action@v3
        with:
          context: "."
          build-args: FEDORA_VERSION=38
          file: watchman/build/package/fedora-env/Dockerfile
          push: true
          tags: "${{ format('ghcr.io/{0}/watchman-build-env-fedora-38:latest', github.repository) }}"
  clone-build-package-ubuntu-20:
    needs:
      - prepare
      - docker-ubuntu-20
    runs-on: ubuntu-latest
    container:
      image: "${{ format('ghcr.io/{0}/watchman-build-env-ubuntu-20:latest', github.repository) }}"
    steps:
      - name: Fix HOME
        run: echo HOME=/root >> $GITHUB_ENV
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Install system dependencies
        run: "./install-system-packages.sh"
      - name: Fix dubious ownership
        run: git config --global --add safe.directory /__w/watchman/watchman
      - name: Build Watchman binaries
        run: "./autogen.sh"
      - name: Make .deb
        env:
          UBUNTU_VERSION: "20.04"
        run: "./watchman/build/package/make-deb.sh"
      - name: Upload .deb
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        uses: actions/upload-release-asset@v1
        with:
          upload_url: "${{ needs.prepare.outputs.upload_url }}"
          asset_path: /_debs/watchman.deb
          asset_name: "watchman_ubuntu20.04_${{ needs.prepare.outputs.release }}.deb"
          asset_content_type: application/x-deb
  clone-build-package-ubuntu-22:
    needs:
      - prepare
      - docker-ubuntu-22
    runs-on: ubuntu-latest
    container:
      image: "${{ format('ghcr.io/{0}/watchman-build-env-ubuntu-22:latest', github.repository) }}"
    steps:
      - name: Fix HOME
        run: echo HOME=/root >> $GITHUB_ENV
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Install system dependencies
        run: "./install-system-packages.sh"
      - name: Fix dubious ownership
        run: git config --global --add safe.directory /__w/watchman/watchman
      - name: Build Watchman binaries
        run: "./autogen.sh"
      - name: Make .deb
        env:
          UBUNTU_VERSION: "22.04"
        run: "./watchman/build/package/make-deb.sh"
      - name: Upload .deb
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        uses: actions/upload-release-asset@v1
        with:
          upload_url: "${{ needs.prepare.outputs.upload_url }}"
          asset_path: /_debs/watchman.deb
          asset_name: "watchman_ubuntu22.04_${{ needs.prepare.outputs.release }}.deb"
          asset_content_type: application/x-deb
  clone-build-package-fedora-36:
    needs:
      - prepare
      - docker-fedora-36
    runs-on: ubuntu-latest
    container:
      image: "${{ format('ghcr.io/{0}/watchman-build-env-fedora-36:latest', github.repository) }}"
    steps:
      - name: Fix HOME
        run: echo HOME=/root >> $GITHUB_ENV
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Install system dependencies
        run: "./install-system-packages.sh"
      - name: Fix dubious ownership
        run: git config --global --add safe.directory /__w/watchman/watchman
      - name: Build Watchman binaries
        run: "./autogen.sh"
      - name: Make .rpm
        id: make_rpm
        env:
          FEDORA_VERSION: "36"
        run: "./watchman/build/package/make-rpm.sh"
      - name: Upload .rpm
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        uses: actions/upload-release-asset@v1
        with:
          upload_url: "${{ needs.prepare.outputs.upload_url }}"
          asset_path: "${{ steps.make_rpm.outputs.rpm_path }}"
          asset_name: "${{ steps.make_rpm.outputs.rpm_name }}"
          asset_content_type: application/x-rpm
  clone-build-package-fedora-37:
    needs:
      - prepare
      - docker-fedora-37
    runs-on: ubuntu-latest
    container:
      image: "${{ format('ghcr.io/{0}/watchman-build-env-fedora-37:latest', github.repository) }}"
    steps:
      - name: Fix HOME
        run: echo HOME=/root >> $GITHUB_ENV
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Install system dependencies
        run: "./install-system-packages.sh"
      - name: Fix dubious ownership
        run: git config --global --add safe.directory /__w/watchman/watchman
      - name: Build Watchman binaries
        run: "./autogen.sh"
      - name: Make .rpm
        id: make_rpm
        env:
          FEDORA_VERSION: "37"
        run: "./watchman/build/package/make-rpm.sh"
      - name: Upload .rpm
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        uses: actions/upload-release-asset@v1
        with:
          upload_url: "${{ needs.prepare.outputs.upload_url }}"
          asset_path: "${{ steps.make_rpm.outputs.rpm_path }}"
          asset_name: "${{ steps.make_rpm.outputs.rpm_name }}"
          asset_content_type: application/x-rpm
  clone-build-package-fedora-38:
    needs:
      - prepare
      - docker-fedora-38
    runs-on: ubuntu-latest
    container:
      image: "${{ format('ghcr.io/{0}/watchman-build-env-fedora-38:latest', github.repository) }}"
    steps:
      - name: Fix HOME
        run: echo HOME=/root >> $GITHUB_ENV
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Install system dependencies
        run: "./install-system-packages.sh"
      - name: Fix dubious ownership
        run: git config --global --add safe.directory /__w/watchman/watchman
      - name: Build Watchman binaries
        run: "./autogen.sh"
      - name: Make .rpm
        id: make_rpm
        env:
          FEDORA_VERSION: "38"
        run: "./watchman/build/package/make-rpm.sh"
      - name: Upload .rpm
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        uses: actions/upload-release-asset@v1
        with:
          upload_url: "${{ needs.prepare.outputs.upload_url }}"
          asset_path: "${{ steps.make_rpm.outputs.rpm_path }}"
          asset_name: "${{ steps.make_rpm.outputs.rpm_name }}"
          asset_content_type: application/x-rpm
  linux-build:
    continue-on-error: true
    needs: prepare
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - name: Build watchman
        run: "python3 build/fbcode_builder/getdeps.py build --src-dir=. watchman  --project-install-prefix watchman:/usr/local"
      - name: Copy artifacts
        run: "python3 build/fbcode_builder/getdeps.py fixup-dyn-deps --strip --src-dir=. watchman _artifacts/linux  --project-install-prefix watchman:/usr/local --final-install-prefix /usr/local"
      - name: Test watchman
        run: "python3 build/fbcode_builder/getdeps.py test --src-dir=. watchman  --project-install-prefix watchman:/usr/local"
      - name: Package watchman
        run: "mv _artifacts/linux \"watchman-${{ needs.prepare.outputs.release }}-linux\" && zip -r watchman-${{ needs.prepare.outputs.release }}-linux.zip \"watchman-${{ needs.prepare.outputs.release }}-linux/\""
      - name: Upload Linux release
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        uses: actions/upload-release-asset@v1
        with:
          upload_url: "${{ needs.prepare.outputs.upload_url }}"
          asset_path: "./watchman-${{ needs.prepare.outputs.release }}-linux.zip"
          asset_name: "watchman-${{ needs.prepare.outputs.release }}-linux.zip"
          asset_content_type: application/zip
  mac-build:
    continue-on-error: true
    needs: prepare
    runs-on: macOS-10.15
    steps:
      - uses: actions/checkout@v2
      - name: Build watchman
        run: "SDKROOT=$(xcrun --show-sdk-path --sdk macosx11.1) python3 build/fbcode_builder/getdeps.py --allow-system-packages build --src-dir=. watchman  --project-install-prefix watchman:/usr/local"
      - name: Copy artifacts
        run: "python3 build/fbcode_builder/getdeps.py --allow-system-packages fixup-dyn-deps --src-dir=. watchman _artifacts/mac  --project-install-prefix watchman:/usr/local --final-install-prefix /usr/local"
      - name: Test watchman
        run: "python3 build/fbcode_builder/getdeps.py --allow-system-packages test --src-dir=. watchman  --project-install-prefix watchman:/usr/local"
      - name: Package watchman
        run: "mv _artifacts/mac \"watchman-${{ needs.prepare.outputs.release }}-macos\" && zip -r watchman-${{ needs.prepare.outputs.release }}-macos.zip \"watchman-${{ needs.prepare.outputs.release }}-macos/\""
      - name: Upload macOS release
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        uses: actions/upload-release-asset@v1
        with:
          upload_url: "${{ needs.prepare.outputs.upload_url }}"
          asset_path: "./watchman-${{ needs.prepare.outputs.release }}-macos.zip"
          asset_name: "watchman-${{ needs.prepare.outputs.release }}-macos.zip"
          asset_content_type: application/zip
  windows-build:
    continue-on-error: true
    needs: prepare
    runs-on: windows-2019
    steps:
      - uses: actions/checkout@v2
      - name: Export boost environment
        run: echo BOOST_ROOT=%BOOST_ROOT_1_69_0% >> %GITHUB_ENV%
        shell: cmd
      - name: Fix Git config
        run: git config --system core.longpaths true
      - name: Build watchman
        run: python build/fbcode_builder/getdeps.py --allow-system-packages build --src-dir=. watchman
      - name: Copy artifacts
        run: python build/fbcode_builder/getdeps.py --allow-system-packages fixup-dyn-deps --src-dir=. watchman _artifacts/windows  --final-install-prefix /usr/local
      - name: Test watchman
        run: python build/fbcode_builder/getdeps.py --allow-system-packages test --src-dir=. watchman
      - name: Package watchman
        run: "mv _artifacts/windows \"watchman-${{ needs.prepare.outputs.release }}-windows\" && Compress-Archive -DestinationPath \"watchman-${{ needs.prepare.outputs.release }}-windows.zip\" -Path \"watchman-${{ needs.prepare.outputs.release }}-windows/\""
      - name: Upload Windows release
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
        uses: actions/upload-release-asset@v1
        with:
          upload_url: "${{ needs.prepare.outputs.upload_url }}"
          asset_path: "./watchman-${{ needs.prepare.outputs.release }}-windows.zip"
          asset_name: "watchman-${{ needs.prepare.outputs.release }}-windows.zip"
          asset_content_type: application/zip