diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e092ecd..24350d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,24 +2,24 @@ name: Build on: push: - branches: [ "main" ] + branches: ["main"] pull_request: branches: [ "main","*" ] jobs: - build: + build-go: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.24' + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.24' - - name: Build - run: go build -v ./... + - name: Build + run: go build -v ./... - - name: Test - run: go test -v ./... + - name: Test + run: go test -v ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bbe4a91 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + +jobs: + release-binaries: + name: Generate cross-platform builds + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Generate build files + uses: thatisuday/go-cross-build@v1 + with: + platforms: | + linux/amd64, + linux/386, + linux/ppc64, + linux/ppc64le, + linux/mips64, + linux/mips64le, + darwin/amd64, + windows/amd64, + windows/386, + freebsd/amd64, + netbsd/amd64, + openbsd/amd64, + dragonfly/amd64, + plan9/amd64, + plan9/386, + solaris/amd64 + package: "" + name: "pulse-bridge" + compress: "false" + dest: "dist" + + build-and-push-docker-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry (GHCR) + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract semver version + id: extract_version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Build and push Docker image with GHA cache + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository_owner }}/pulse-bridge:${{ steps.extract_version.outputs.VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max