|
5 | 5 | tags:
|
6 | 6 | - 'v*'
|
7 | 7 |
|
| 8 | +env: |
| 9 | + REGISTRY_IMAGE: goharbor/harbor-acceld |
| 10 | + |
8 | 11 | jobs:
|
9 |
| - release_image: |
| 12 | + build_image: |
10 | 13 | runs-on: ubuntu-20.04
|
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + platform: |
| 17 | + - linux/amd64 |
| 18 | + - linux/arm64 |
11 | 19 | steps:
|
12 | 20 | - name: Checkout Code
|
13 | 21 | uses: actions/checkout@v4
|
14 |
| - |
15 |
| - - name: Export Image Tag |
| 22 | + - name: Prepare |
16 | 23 | run: |
|
17 |
| - echo "IMAGE_TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV |
18 |
| -
|
| 24 | + platform=${{ matrix.platform }} |
| 25 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 26 | + - name: Docker meta |
| 27 | + id: meta |
| 28 | + uses: docker/metadata-action@v5 |
| 29 | + with: |
| 30 | + images: ${{ env.REGISTRY_IMAGE }} |
| 31 | + tags: | |
| 32 | + type=semver,pattern={{version}} |
19 | 33 | - name: Set up QEMU
|
20 |
| - uses: docker/setup-qemu-action@v2 |
21 |
| - |
| 34 | + uses: docker/setup-qemu-action@v3 |
22 | 35 | - name: Set up Docker Buildx
|
23 |
| - uses: docker/setup-buildx-action@v2 |
24 |
| - |
25 |
| - - name: Build and Export to Docker |
26 |
| - uses: docker/build-push-action@v4 |
27 |
| - with: |
28 |
| - context: . |
29 |
| - file: script/release/Dockerfile |
30 |
| - load: true |
31 |
| - tags: goharbor/harbor-acceld:${{ env.IMAGE_TAG }} |
32 |
| - |
33 |
| - - name: Test Image |
34 |
| - # Enable tty for docker |
35 |
| - shell: 'script -q -e -c "bash {0}"' |
36 |
| - run: | |
37 |
| - docker run -v $PWD/misc/config/config.nydus.yaml:/etc/acceld-config.yaml -d --rm -p 2077:2077 goharbor/harbor-acceld:${{ env.IMAGE_TAG }} /etc/acceld-config.yaml |
38 |
| - sleep 5 |
39 |
| - curl -f http://127.0.0.1:2077/api/v1/health |
40 |
| -
|
| 36 | + uses: docker/setup-buildx-action@v3 |
41 | 37 | - name: Login to DockerHub
|
42 |
| - uses: docker/login-action@v2 |
| 38 | + uses: docker/login-action@v3 |
43 | 39 | with:
|
44 | 40 | username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
45 | 41 | password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
46 |
| - |
47 |
| - - name: Build and Push |
48 |
| - uses: docker/build-push-action@v4 |
| 42 | + - name: Build and push by digest |
| 43 | + id: build |
| 44 | + uses: docker/build-push-action@v5 |
49 | 45 | with:
|
50 | 46 | context: .
|
| 47 | + platforms: ${{ matrix.platform }} |
51 | 48 | file: script/release/Dockerfile
|
52 |
| - push: ${{ github.event_name != 'pull_request' }} |
53 |
| - tags: goharbor/harbor-acceld:${{ env.IMAGE_TAG }} |
| 49 | + labels: ${{ steps.meta.outputs.labels }} |
| 50 | + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true |
| 51 | + - name: Export digest |
| 52 | + run: | |
| 53 | + mkdir -p /tmp/digests |
| 54 | + digest="${{ steps.build.outputs.digest }}" |
| 55 | + touch "/tmp/digests/${digest#sha256:}" |
| 56 | + - name: Upload digest |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 60 | + path: /tmp/digests/* |
| 61 | + if-no-files-found: error |
| 62 | + retention-days: 1 |
| 63 | + |
| 64 | + release_image: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: |
| 67 | + - build_image |
| 68 | + steps: |
| 69 | + - name: Checkout Code |
| 70 | + uses: actions/checkout@v4 |
| 71 | + - name: Download digests |
| 72 | + uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + path: /tmp/digests |
| 75 | + pattern: digests-* |
| 76 | + merge-multiple: true |
| 77 | + - name: Set up Docker Buildx |
| 78 | + uses: docker/setup-buildx-action@v3 |
| 79 | + - name: Docker meta |
| 80 | + id: meta |
| 81 | + uses: docker/metadata-action@v5 |
| 82 | + with: |
| 83 | + images: ${{ env.REGISTRY_IMAGE }} |
| 84 | + tags: | |
| 85 | + type=semver,pattern={{version}} |
| 86 | + - name: Login to DockerHub |
| 87 | + uses: docker/login-action@v3 |
| 88 | + with: |
| 89 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 90 | + password: ${{ secrets.DOCKER_HUB_PASSWORD }} |
| 91 | + - name: Create manifest list and push |
| 92 | + working-directory: /tmp/digests |
| 93 | + run: | |
| 94 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 95 | + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
| 96 | + - name: Inspect image |
| 97 | + run: | |
| 98 | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
| 99 | + - name: Update repo description |
| 100 | + uses: peter-evans/dockerhub-description@v3 |
| 101 | + with: |
| 102 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 103 | + password: ${{ secrets.DOCKER_HUB_PASSWORD }} |
| 104 | + repository: ${{ env.REGISTRY_IMAGE }} |
| 105 | + short-description: "A general service to support image acceleration based on kinds of accelerator like Nydus" |
| 106 | + readme-filepath: ./README.md |
| 107 | + |
| 108 | + test_image: |
| 109 | + runs-on: ubuntu-latest |
| 110 | + strategy: |
| 111 | + matrix: |
| 112 | + arch: [amd64, arm64] |
| 113 | + needs: |
| 114 | + - release_image |
| 115 | + steps: |
| 116 | + - name: Checkout Code |
| 117 | + uses: actions/checkout@v4 |
| 118 | + - name: Test Image |
| 119 | + # Enable tty for docker |
| 120 | + shell: 'script -q -e -c "bash {0}"' |
| 121 | + run: | |
| 122 | + docker run -v $PWD/misc/config/config.nydus.yaml:/etc/acceld-config.yaml -d --rm -p 2077:2077 ${{ env.REGISTRY_IMAGE }} /etc/acceld-config.yaml |
| 123 | + sleep 5 |
| 124 | + curl -f http://127.0.0.1:2077/api/v1/health |
54 | 125 |
|
55 | 126 | release_binary:
|
56 | 127 | runs-on: ubuntu-20.04
|
|
0 commit comments