--- # Github Actions build for rclone # -*- compile-command: "yamllint -f parsable build.yml" -*- name: Build & Push Binary Builds concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} cancel-in-progress: true # Trigger the workflow on push or pull request on: push: branches: - '**' tags: - '**' pull_request: workflow_dispatch: inputs: manual: description: Manual run (bypass default conditions) type: boolean default: true jobs: build: if: inputs.manual || (github.repository == 'rclone/rclone' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)) timeout-minutes: 60 strategy: fail-fast: false matrix: job_name: ['linux', 'linux_386', 'mac_amd64', 'mac_arm64', 'windows', 'other_os', 'go1.23'] include: - job_name: linux platform: linux/amd64/go1.24 os: ubuntu-latest go: '>=1.24.0-rc.1' gotags: cmount build_flags: '-include "^linux/"' check: true quicktest: true racequicktest: true librclonetest: true deploy: true - job_name: linux_386 platform: linux/386/go1.24 os: ubuntu-latest go: '>=1.24.0-rc.1' goarch: 386 gotags: cmount quicktest: true - job_name: mac_amd64 platform: darwin/amd64/go1.24 os: macos-latest go: '>=1.24.0-rc.1' gotags: 'cmount' build_flags: '-include "^darwin/amd64" -cgo' quicktest: true racequicktest: true deploy: true - job_name: mac_arm64 platform: darwin/arm64/go1.24 os: macos-latest go: '>=1.24.0-rc.1' gotags: 'cmount' build_flags: '-include "^darwin/arm64" -cgo -macos-arch arm64 -cgo-cflags=-I/usr/local/include -cgo-ldflags=-L/usr/local/lib' deploy: true - job_name: windows platform: windows/amd64/go1.24 os: windows-latest go: '>=1.24.0-rc.1' gotags: cmount cgo: '0' build_flags: '-include "^windows/"' build_args: '-buildmode exe' quicktest: true deploy: true - job_name: other_os platform: linux/amd64/other/go1.24 os: ubuntu-latest go: '>=1.24.0-rc.1' build_flags: '-exclude "^(windows/|darwin/|linux/)"' compile_all: true deploy: true - job_name: go1.23 platform: linux/amd64/go1.23 os: ubuntu-latest go: '1.23' quicktest: true racequicktest: true name: ${{ matrix.job_name }} runs-on: ${{ matrix.os }} steps: - name: Checkout Repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install Go uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} check-latest: true cache: false - name: Install FUSE & Libraries on Linux shell: bash run: | sudo modprobe fuse sudo chmod 666 /dev/fuse sudo chown root:$USER /etc/fuse.conf sudo apt-get update sudo apt-get install -y fuse3 libfuse-dev rpm pkg-config git-annex git-annex-remote-rclone nfs-common if: matrix.os == 'ubuntu-latest' - name: Install FUSE & Libraries on macOS shell: bash run: | # https://github.com/Homebrew/brew/issues/15621#issuecomment-1619266788 # https://github.com/orgs/Homebrew/discussions/4612#discussioncomment-6319008 unset HOMEBREW_NO_INSTALL_FROM_API brew untap --force homebrew/core brew untap --force homebrew/cask brew update brew install --cask macfuse brew install git-annex git-annex-remote-rclone if: matrix.os == 'macos-latest' - name: Install FUSE & Libraries on Windows shell: powershell run: | $ProgressPreference = 'SilentlyContinue' choco install -y winfsp zip echo "CPATH=C:\Program Files\WinFsp\inc\fuse;C:\Program Files (x86)\WinFsp\inc\fuse" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append if ($env:GOARCH -eq "386") { choco install -y mingw --forcex86 --force echo "C:\\ProgramData\\chocolatey\\lib\\mingw\\tools\\install\\mingw32\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append } # Copy mingw32-make.exe to make.exe so the same command line # can be used on Windows as on macOS and Linux $path = (get-command mingw32-make.exe).Path Copy-Item -Path $path -Destination (Join-Path (Split-Path -Path $path) 'make.exe') if: matrix.os == 'windows-latest' - name: Set Environment Variables shell: bash run: | echo 'GOTAGS=${{ matrix.gotags }}' >> $GITHUB_ENV echo 'BUILD_FLAGS=${{ matrix.build_flags }}' >> $GITHUB_ENV echo 'BUILD_ARGS=${{ matrix.build_args }}' >> $GITHUB_ENV if [[ "${{ matrix.goarch }}" != "" ]]; then echo 'GOARCH=${{ matrix.goarch }}' >> $GITHUB_ENV ; fi if [[ "${{ matrix.cgo }}" != "" ]]; then echo 'CGO_ENABLED=${{ matrix.cgo }}' >> $GITHUB_ENV ; fi - name: Set Go Environment Variables shell: bash run: | echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV if: matrix.os != 'windows-latest' - name: Set Go Environment Variables # This is necessary for Windows because the default location of C: is particularly slow for github runners: https://github.com/actions/setup-go/pull/515 shell: bash run: | echo "GOCACHE=D:\gocache" >> $GITHUB_ENV echo "GOMODCACHE=D:\gomodcache" >> $GITHUB_ENV echo "GOTMPDIR=D:\gotmp" >> $GITHUB_ENV mkdir D:/gocache D:/gomodcache D:/gotmp if: matrix.os == 'windows-latest' - name: Set PLATFORM Variable shell: bash run: | platform=${{ matrix.platform }} echo "PLATFORM=${platform//\//-}" >> $GITHUB_ENV - name: Get ImageOS # There's no way around this, because "ImageOS" is only available to # processes, but the setup-go action uses it in its key. id: imageos uses: actions/github-script@v7 with: result-encoding: string script: | return process.env.ImageOS - name: Set CACHE_PREFIX Variable shell: bash run: | cache_prefix=${{ runner.os }}-${{ steps.imageos.outputs.result }}-${{ env.PLATFORM }} echo "CACHE_PREFIX=${cache_prefix}" >> $GITHUB_ENV - name: Print Go Version and Environment shell: bash run: | printf "Using go at: $(which go)\n" printf "Go version: $(go version)\n" printf "\n\nGo environment:\n\n" go env printf "\n\nRclone environment:\n\n" make vars printf "\n\nSystem environment:\n\n" env - name: Load Go Module Cache uses: actions/cache@v4 with: path: | ${{ env.GOMODCACHE }} key: ${{ env.CACHE_PREFIX }}-modcache-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ env.CACHE_PREFIX }}-modcache # Both load & update the cache when on default branch - name: Load Go Build & Test Cache id: go-cache uses: actions/cache@v4 if: github.ref_name == github.event.repository.default_branch && github.event_name != 'pull_request' with: path: | ${{ env.GOCACHE }} key: ${{ env.CACHE_PREFIX }}-cache-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}-${{ github.run_id }} restore-keys: | ${{ env.CACHE_PREFIX }}-cache # Only load the cache when not on default branch - name: Load Go Build & Test Cache id: go-cache-restore uses: actions/cache/restore@v4 if: github.ref_name != github.event.repository.default_branch || github.event_name == 'pull_request' with: path: | ${{ env.GOCACHE }} key: ${{ env.CACHE_PREFIX }}-cache-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}-${{ github.run_id }} restore-keys: | ${{ env.CACHE_PREFIX }}-cache - name: Build rclone shell: bash run: | make - name: Print rclone Version shell: bash run: | rclone version - name: Update mtime shell: bash run: | go run ./bin/go-test-cache/main.go - name: Run Tests shell: bash run: | make quicktest if: matrix.quicktest - name: Race Test shell: bash run: | make racequicktest if: (success() || failure()) && matrix.racequicktest - name: Run librclone Tests shell: bash run: | make -C librclone/ctest test make -C librclone/ctest clean librclone/python/test_rclone.py if: (success() || failure()) && matrix.librclonetest - name: Compile All Architectures Test shell: bash run: | make make compile_all if: (success() || failure()) && matrix.compile_all - name: Delete Existing Cache continue-on-error: true shell: bash env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cache_ids=($(gh cache list --key "${{ env.CACHE_PREFIX }}-cache" --json id | jq '.[].id')) for cache_id in "${cache_ids[@]}"; do echo "Deleting Cache: $cache_id" gh cache delete "$cache_id" done if: (success() || failure()) && github.ref_name == github.event.repository.default_branch && github.event_name != 'pull_request' && steps.go-cache.outputs.cache-hit != 'true' - name: Deploy Built Binaries shell: bash run: | if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then make release_dep_linux ; fi make ci_beta env: RCLONE_CONFIG_PASS: ${{ secrets.RCLONE_CONFIG_PASS }} # working-directory: '$(modulePath)' # Deploy binaries if enabled in config && not a PR && not a fork if: env.RCLONE_CONFIG_PASS != '' && matrix.deploy && github.head_ref == '' && github.repository == 'rclone/rclone'