| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- name: ci
- concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
- on:
- push:
- branches:
- - 'v2'
- tags:
- - 'v*'
- pull_request:
- workflow_dispatch:
- inputs:
- debug_enabled:
- description: 'To run with tmate enter "debug_enabled"'
- required: false
- default: "false"
- env:
- GO_VERSION: "1.18.5" # for non sandboxed e2e tests
- DESTDIR: "./bin"
- DOCKER_CLI_VERSION: "20.10.17"
- jobs:
- prepare:
- runs-on: ubuntu-latest
- outputs:
- matrix: ${{ steps.platforms.outputs.matrix }}
- steps:
- -
- name: Checkout
- uses: actions/checkout@v3
- -
- name: Create matrix
- id: platforms
- run: |
- echo ::set-output name=matrix::$(docker buildx bake binary-cross --print | jq -cr '.target."binary-cross".platforms')
- -
- name: Show matrix
- run: |
- echo ${{ steps.platforms.outputs.matrix }}
- validate:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- target:
- - lint
- - validate-go-mod
- - validate-headers
- - validate-docs
- steps:
- -
- name: Checkout
- uses: actions/checkout@v3
- -
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- -
- name: Run
- run: |
- make ${{ matrix.target }}
- binary:
- runs-on: ubuntu-latest
- needs:
- - prepare
- strategy:
- fail-fast: false
- matrix:
- platform: ${{ fromJson(needs.prepare.outputs.matrix) }}
- steps:
- -
- name: Prepare
- run: |
- platform=${{ matrix.platform }}
- echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- -
- name: Checkout
- uses: actions/checkout@v3
- -
- name: Set up QEMU
- uses: docker/setup-qemu-action@v2
- -
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- -
- name: Build
- uses: docker/bake-action@v2
- with:
- targets: release
- set: |
- *.platform=${{ matrix.platform }}
- *.cache-from=type=gha,scope=binary-${{ env.PLATFORM_PAIR }}
- *.cache-to=type=gha,scope=binary-${{ env.PLATFORM_PAIR }},mode=max
- -
- name: Upload artifacts
- uses: actions/upload-artifact@v3
- with:
- name: compose
- path: ${{ env.DESTDIR }}/*
- if-no-files-found: error
- test:
- runs-on: ubuntu-latest
- steps:
- -
- name: Checkout
- uses: actions/checkout@v3
- -
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- -
- name: Test
- uses: docker/bake-action@v2
- with:
- targets: test
- set: |
- *.cache-from=type=gha,scope=test
- *.cache-to=type=gha,scope=test
- e2e:
- runs-on: ubuntu-latest
- env:
- DESTDIR: "./bin/build"
- strategy:
- fail-fast: false
- matrix:
- mode:
- - plugin
- - standalone
- steps:
- -
- name: Checkout
- uses: actions/checkout@v3
- -
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- -
- name: Set up Go
- uses: actions/setup-go@v3
- with:
- go-version: ${{ env.GO_VERSION }}
- cache: true
- -
- name: Setup docker CLI
- run: |
- curl https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz | tar xz
- sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
- -
- name: Build
- uses: docker/bake-action@v2
- with:
- targets: binary
- set: |
- *.cache-from=type=gha,scope=binary-linux-amd64
- *.cache-from=type=gha,scope=binary-e2e-${{ matrix.mode }}
- *.cache-to=type=gha,scope=binary-e2e-${{ matrix.mode }},mode=max
- env:
- BUILD_TAGS: e2e
- -
- name: Setup tmate session
- if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
- uses: mxschmitt/action-tmate@8b4e4ac71822ed7e0ad5fb3d1c33483e9e8fb270 # v3.11
- with:
- limit-access-to-actor: true
- github-token: ${{ secrets.GITHUB_TOKEN }}
- -
- name: Test plugin mode
- if: ${{ matrix.mode == 'plugin' }}
- run: |
- make e2e-compose
- -
- name: Test standalone mode
- if: ${{ matrix.mode == 'standalone' }}
- run: |
- rm -f /usr/local/bin/docker-compose
- cp bin/build/docker-compose /usr/local/bin
- make e2e-compose-standalone
- release:
- runs-on: ubuntu-latest
- needs:
- - binary
- steps:
- -
- name: Checkout
- uses: actions/checkout@v3
- -
- name: Download artifacts
- uses: actions/download-artifact@v3
- with:
- name: compose
- path: ${{ env.DESTDIR }}
- -
- name: Create checksums
- working-directory: ${{ env.DESTDIR }}
- run: |
- find . -type f -print0 | sort -z | xargs -r0 shasum -a 256 -b | sed 's# .*/# #' > checksums.txt
- shasum -a 256 -U -c checksums.txt
- -
- name: License
- run: cp packaging/* ${{ env.DESTDIR }}/
- -
- name: List artifacts
- run: |
- tree -nh ${{ env.DESTDIR }}
- -
- name: Check artifacts
- run: |
- find ${{ env.DESTDIR }} -type f -exec file -e ascii -- {} +
- -
- name: GitHub Release
- if: startsWith(github.ref, 'refs/tags/v')
- uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # v1.10.0
- with:
- artifacts: ${{ env.DESTDIR }}/*
- generateReleaseNotes: true
- draft: true
- token: ${{ secrets.GITHUB_TOKEN }}
|