diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..980d6f6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: + - main + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + arch: [amd64, arm64] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: '1.22' + + - name: Build binary + run: | + GOARCH=${{ matrix.arch }} + GOOS=linux go build -o bbx-${GOARCH} + + - name: Upload binaries + uses: actions/upload-artifact@v2 + with: + name: bbx-${{ matrix.arch }} + path: bbx-${{ matrix.arch }} + + release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + run: | + docker buildx build --platform linux/amd64,linux/arm64 -t snail2sky/bbx:latest . --push + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag: ${{ github.ref }} + files: | + bbx-amd64 + bbx-arm64 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}