Merge pull request #221 from PerseidMeteor/feat-cache-version #29
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
release_image: | |
runs-on: ubuntu-20.04 | |
env: | |
GO_VERSION: 1.18 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Export Image Tag | |
run: | | |
echo "IMAGE_TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and Export to Docker | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: script/release/Dockerfile | |
load: true | |
tags: goharbor/harbor-acceld:${{ env.IMAGE_TAG }} | |
- 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 goharbor/harbor-acceld:${{ env.IMAGE_TAG }} /etc/acceld-config.yaml | |
sleep 5 | |
curl -f http://127.0.0.1:2077/api/v1/health | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build and Push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: script/release/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: goharbor/harbor-acceld:${{ env.IMAGE_TAG }} | |
release_binary: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
arch: [amd64, arm64] | |
env: | |
GO_VERSION: 1.18 | |
OUTPUT_DIR: ${{ github.workspace }}/out | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- 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@v3 | |
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@v3 | |
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[@]}" |