diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..6b3d40b --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,36 @@ +name: Docker Build and Publish + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile-optimized + push: ${{ github.event_name != 'pull_request' }} + tags: | + ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 4e1b159..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: build relay for all platforms - -on: - push: - tags: - - "*" - -permissions: - contents: write - -jobs: - make-release: - runs-on: ubuntu-latest - steps: - - name: Install build-essential and LMDB development files - run: | - sudo apt-get update - sudo apt-get install -y build-essential liblmdb-dev - - - name: Create Release - uses: actions/create-release@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref_name }} - release_name: ${{ github.ref_name }} - continue-on-error: true - - build-all-for-all: - runs-on: ubuntu-latest - needs: - - make-release - strategy: - matrix: - goos: [linux, freebsd, darwin, windows] - goarch: [amd64, arm64, riscv64] - exclude: - - goarch: arm64 - goos: windows - - goarch: riscv64 - goos: windows - - goarch: riscv64 - goos: darwin - steps: - - uses: actions/checkout@v3 - - - name: Install build-essential and LMDB development files - run: | - sudo apt-get update - sudo apt-get install -y build-essential liblmdb-dev - - - name: Set CGO_ENABLED=1 - run: | - export CGO_ENABLED=1 - - - name: Build application with Go - run: | - go env # Print Go environment details for debugging - go build ./... - - - uses: wangyoucao577/go-release-action@v1.40 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: ${{ matrix.goos }} - goarch: ${{ matrix.goarch }} - overwrite: true - md5sum: false - sha256sum: false - compress_assets: false