Skip to content

Merge pull request #328 from goharbor/dependabot/docker/script/releas… #32

Merge pull request #328 from goharbor/dependabot/docker/script/releas…

Merge pull request #328 from goharbor/dependabot/docker/script/releas… #32

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
env:
REGISTRY_IMAGE: goharbor/harbor-acceld
jobs:
build_image:
runs-on: ubuntu-20.04
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
file: script/release/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
release_image:
runs-on: ubuntu-latest
needs:
- build_image
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=semver,pattern={{version}}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
- name: Update repo description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
repository: ${{ env.REGISTRY_IMAGE }}
short-description: "A general service to support image acceleration based on kinds of accelerator like Nydus"
readme-filepath: ./README.md
test_image:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
needs:
- release_image
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Test Image
# Enable tty for docker
shell: 'script -q -e -c "bash {0}"'
run: |
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
sleep 5
curl -f http://127.0.0.1:2077/api/v1/health
release_binary:
runs-on: ubuntu-20.04
strategy:
matrix:
arch: [amd64, arm64]
env:
OUTPUT_DIR: ${{ github.workspace }}/out
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run Linter
run: |
make install-check-tools
make check
- name: Build Binary
run: |
make -e GOARCH=${{ matrix.arch }}
- name: Pack Binary
run: |
TAG=$GITHUB_REF_NAME
TARGZ_FILE="harbor-acceld-$TAG-linux-${{ matrix.arch }}.tgz"
SHA256SUM_FILE="harbor-acceld-$TAG-linux-${{ matrix.arch }}.tgz.sha256sum"
mkdir $OUTPUT_DIR && mkdir harbor-acceld && mv acceld harbor-acceld/. && mv accelctl harbor-acceld/.
tar cf - harbor-acceld | gzip > $OUTPUT_DIR/${TARGZ_FILE}
sha256sum $OUTPUT_DIR/${TARGZ_FILE} > $OUTPUT_DIR/${SHA256SUM_FILE}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: harbor-acceld-artifacts
path: |
${{ env.OUTPUT_DIR }}
upload_binary:
runs-on: ubuntu-20.04
env:
OUTPUT_DIR: ${{ github.workspace }}/out
needs: [release_binary]
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: harbor-acceld-artifacts
path: |
${{ env.OUTPUT_DIR }}
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG=$GITHUB_REF_NAME
cat <<EOF > ${GITHUB_WORKSPACE}/release-note.txt
Acceleration Service ${TAG} Release
(TBD)
EOF
ASSET_ARGS=()
for F in ${OUTPUT_DIR}/* ; do
ASSET_ARGS+=("$F")
done
gh release create -F ${GITHUB_WORKSPACE}/release-note.txt --draft --title $TAG $TAG "${ASSET_ARGS[@]}"