From df6997a8e1d4ed6cd5495a0a0c219758da62bb3f Mon Sep 17 00:00:00 2001 From: "Bo-Yi.Wu" Date: Sat, 24 Dec 2022 21:16:51 +0800 Subject: [PATCH] chore(CI): add build config Signed-off-by: Bo-Yi.Wu --- .github/workflows/build.yml | 138 ++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..13c81e7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,138 @@ +name: Release Binary + +on: + push: + branches: + - master + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: '^1' + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Build binary + run : | + make build_linux_amd64 + make build_linux_arm64 + make build_linux_arm + + - name: Check binary + run : | + ./release/linux/amd64/drone-ssh --help + + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - + name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - + name: Docker meta for linux amd64 + id: meta-linux-amd64 + uses: docker/metadata-action@v4 + with: + flavor: | + latest=false + suffix=linux-amd64 + images: | + appleboy/drone-ssh + ghcr.io/appleboy/drone-ssh + tags: | + type=raw,value= + type=raw,value=latest,suffix=,enable={{is_default_branch}} + type=semver,event=tag,pattern={{version}},suffix=-linux-amd64 + type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-amd64 + type=semver,event=tag,pattern={{major}},suffix=-linux-amd64 + + - + name: Build and push linux amd64 + uses: docker/build-push-action@v3 + with: + context: . + file: docker/Dockerfile.linux.amd64 + platforms: linux/amd64 + push: true + tags: ${{ steps.meta-linux-amd64.outputs.tags }} + labels: ${{ steps.meta-linux-amd64.outputs.labels }} + + - + name: Docker meta for linux arm64 + id: meta-linux-arm64 + uses: docker/metadata-action@v4 + with: + flavor: | + latest=false + suffix=linux-arm64 + images: | + appleboy/drone-ssh + ghcr.io/appleboy/drone-ssh + tags: | + type=raw,value= + type=semver,event=tag,pattern={{version}},suffix=-linux-arm64 + type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm64 + type=semver,event=tag,pattern={{major}},suffix=-linux-arm64 + + - + name: Build and push linux arm64 + uses: docker/build-push-action@v3 + with: + context: . + file: docker/Dockerfile.linux.arm64 + platforms: linux/arm64 + push: true + tags: ${{ steps.meta-linux-arm64.outputs.tags }} + labels: ${{ steps.meta-linux-arm64.outputs.labels }} + + - + name: Docker meta for linux arm + id: meta-linux-arm + uses: docker/metadata-action@v4 + with: + flavor: | + latest=false + suffix=linux-arm + images: | + appleboy/drone-ssh + ghcr.io/appleboy/drone-ssh + tags: | + type=raw,value= + type=semver,event=tag,pattern={{version}},suffix=-linux-arm + type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm + type=semver,event=tag,pattern={{major}},suffix=-linux-arm + + - + name: Build and push linux arm + uses: docker/build-push-action@v3 + with: + context: . + file: docker/Dockerfile.linux.arm + platforms: linux/arm + push: true + tags: ${{ steps.meta-linux-arm.outputs.tags }} + labels: ${{ steps.meta-linux-arm.outputs.labels }}