Skip to content

Commit

Permalink
setup build cloud builder
Browse files Browse the repository at this point in the history
bump gihub action version

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
  • Loading branch information
glours committed Mar 26, 2024
1 parent 4b7b6ad commit 0e0337f
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 54 deletions.
138 changes: 98 additions & 40 deletions .github/workflows/ci.yml
Expand Up @@ -21,6 +21,7 @@ on:
permissions:
contents: read # to fetch code (actions/checkout)


jobs:
prepare:
runs-on: ubuntu-latest
Expand All @@ -29,7 +30,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Create matrix
id: platforms
Expand All @@ -53,10 +54,21 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERPUBLICBOT_USERNAME }}
password: ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: ${{ github.event_name != 'pull_request' && 'cloud' || '' }}
endpoint: ${{ github.event_name != 'pull_request' && secrets.DOCKER_BUILD_CLOUD_ENDPOINT || '' }}
-
name: Run
run: |
Expand All @@ -78,16 +90,29 @@ jobs:
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

-
name: Login
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERPUBLICBOT_USERNAME }}
password: ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
if: github.event_name != 'pull_request'
version: "lab:latest"
driver: ${{ github.event_name != 'pull_request' && 'cloud' || '' }}
endpoint: ${{ github.event_name != 'pull_request' && secrets.DOCKER_BUILD_CLOUD_ENDPOINT || '' }}
-
name: Build
uses: docker/bake-action@v2
uses: docker/bake-action@v4
with:
targets: release
set: |
Expand All @@ -96,32 +121,44 @@ jobs:
*.cache-to=type=gha,scope=binary-${{ env.PLATFORM_PAIR }},mode=max
-
name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: compose
path: ./bin/release/*
name: compose-${{ env.PLATFORM_PAIR }}
path: ./bin/release
if-no-files-found: error

test:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

-
name: Login
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERPUBLICBOT_USERNAME }}
password: ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: ${{ github.event_name != 'pull_request' && 'cloud' || '' }}
endpoint: ${{ github.event_name != 'pull_request' && secrets.DOCKER_BUILD_CLOUD_ENDPOINT || '' }}
-
name: Test
uses: docker/bake-action@v2
uses: docker/bake-action@v4
with:
targets: test
set: |
*.cache-from=type=gha,scope=test
*.cache-to=type=gha,scope=test
-
name: Gather coverage data
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-data-unit
path: bin/coverage/unit/
Expand All @@ -147,27 +184,40 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
- name: Install Docker ${{ matrix.engine }}
uses: actions/checkout@v4
-
name: Install Docker ${{ matrix.engine }}
run: |
sudo apt-get install curl
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh --version ${{ matrix.engine }}
- name: Check Docker Version
-
name: Check Docker Version
run: docker --version
-
name: Login
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERPUBLICBOT_USERNAME }}
password: ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: ${{ github.event_name != 'pull_request' && 'cloud' || '' }}
endpoint: ${{ github.event_name != 'pull_request' && secrets.DOCKER_BUILD_CLOUD_ENDPOINT || '' }}
-
name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
check-latest: true
cache: true
-
name: Build
uses: docker/bake-action@v2
uses: docker/bake-action@v4
with:
targets: binary-with-coverage
set: |
Expand All @@ -193,7 +243,7 @@ jobs:
-
name: Gather coverage data
if: ${{ matrix.mode == 'plugin' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-data-e2e
path: bin/coverage/e2e/
Expand All @@ -218,34 +268,41 @@ jobs:
- e2e
steps:
# codecov won't process the report without the source code available
- name: Checkout
-
name: Checkout
uses: actions/checkout@v3
- name: Set up Go
-
name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
check-latest: true
- name: Download unit test coverage
uses: actions/download-artifact@v3
-
name: Download unit test coverage
uses: actions/download-artifact@v4
with:
name: coverage-data-unit
path: coverage/unit
- name: Download E2E test coverage
uses: actions/download-artifact@v3
-
name: Download E2E test coverage
uses: actions/download-artifact@v4
with:
name: coverage-data-e2e
path: coverage/e2e
- name: Merge coverage reports
-
name: Merge coverage reports
run: |
go tool covdata textfmt -i=./coverage/unit,./coverage/e2e -o ./coverage.txt
- name: Store coverage report in GitHub Actions
-
name: Store coverage report in GitHub Actions
uses: actions/upload-artifact@v3
with:
name: go-covdata-txt
path: ./coverage.txt
if-no-files-found: error
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
-
name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.txt

Expand All @@ -259,38 +316,39 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: compose
path: bin/release
pattern: compose-*
path: ./bin/release
merge-multiple: true
-
name: Create checksums
working-directory: bin/release
working-directory: ./bin/release
run: |
find . -type f -print0 | sort -z | xargs -r0 shasum -a 256 -b | sed 's# \*\./# *#' > $RUNNER_TEMP/checksums.txt
shasum -a 256 -U -c $RUNNER_TEMP/checksums.txt
mv $RUNNER_TEMP/checksums.txt .
cat checksums.txt | while read sum file; do echo "$sum $file" > ${file#\*}.sha256; done
-
name: License
run: cp packaging/* bin/release/
run: cp packaging/* ./bin/release
-
name: List artifacts
run: |
tree -nh bin/release
tree -nh ./bin/release
-
name: Check artifacts
run: |
find bin/release -type f -exec file -e ascii -- {} +
find ./bin/release -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: bin/release/*
artifacts: ./bin/release/*
generateReleaseNotes: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
32 changes: 18 additions & 14 deletions .github/workflows/merge.yml
Expand Up @@ -31,9 +31,9 @@ jobs:
env:
GO111MODULE: "on"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
Expand Down Expand Up @@ -81,34 +81,38 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERPUBLICBOT_USERNAME }}
password: ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: ${{ secrets.DOCKER_BUILD_CLOUD_ENDPOINT }}
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
${{ env.REPO_SLUG }}
tags: |
type=ref,event=tag
type=edge
bake-target: meta-helper
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERPUBLICBOT_USERNAME }}
password: ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }}
-
name: Build and push image
uses: docker/bake-action@v2
uses: docker/bake-action@v4
id: bake
with:
files: |
Expand Down

0 comments on commit 0e0337f

Please sign in to comment.