From e233f281a49e2a6b8483cbef1642a7683c73cbe9 Mon Sep 17 00:00:00 2001 From: Shehan Chamudith Udakumbura Date: Wed, 23 Jul 2025 11:39:25 +0530 Subject: [PATCH 1/5] feat: build and push docker image to ghcr workflow --- .github/workflows/build-and-push-ghcr.yml | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/build-and-push-ghcr.yml diff --git a/.github/workflows/build-and-push-ghcr.yml b/.github/workflows/build-and-push-ghcr.yml new file mode 100644 index 0000000..1a4a317 --- /dev/null +++ b/.github/workflows/build-and-push-ghcr.yml @@ -0,0 +1,41 @@ +name: Build and Push Docker Image to GHCR + +on: + push: + tags: + - "v*.*.*" + +jobs: + build-and-push: + 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 }}/pulsebridge:${{ steps.extract_version.outputs.VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max From 2a9d75b39b2e1da8ae5c90982da760e2a7b9ef16 Mon Sep 17 00:00:00 2001 From: Shehan Chamudith Udakumbura Date: Thu, 24 Jul 2025 18:19:34 +0530 Subject: [PATCH 2/5] feat: build workflow before build and push --- .github/workflows/build-and-push-ghcr.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/build-and-push-ghcr.yml b/.github/workflows/build-and-push-ghcr.yml index 1a4a317..644e98a 100644 --- a/.github/workflows/build-and-push-ghcr.yml +++ b/.github/workflows/build-and-push-ghcr.yml @@ -4,10 +4,30 @@ on: push: tags: - "v*.*.*" + workflow_dispatch: jobs: + build-go: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.24' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... + build-and-push: + needs: build-go runs-on: ubuntu-latest + if: ${{ github.ref_type == 'tag' }} permissions: contents: read From 2bc5d7bd4d0ccd20dbbca795c4bcf174e90207b7 Mon Sep 17 00:00:00 2001 From: Shehan Chamudith Udakumbura Date: Mon, 28 Jul 2025 16:20:30 +0530 Subject: [PATCH 3/5] fix: use two seperate scripts for build-go and docker build --- .github/workflows/binaries.yml | 20 +++++++++++ .github/workflows/build.yml | 34 +++++++++++++------ .../{build-and-push-ghcr.yml => docker.yml} | 26 ++------------ 3 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/binaries.yml rename .github/workflows/{build-and-push-ghcr.yml => docker.yml} (63%) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml new file mode 100644 index 0000000..f5f4b30 --- /dev/null +++ b/.github/workflows/binaries.yml @@ -0,0 +1,20 @@ +name: Generate release-artifacts + +on: + workflow_call: + +jobs: + generate: + name: Generate cross-platform builds + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + - name: Generate build files + uses: thatisuday/go-cross-build@v1 + with: + platforms: 'linux/amd64, darwin/amd64, windows/amd64' + package: '' + name: 'pulse-bridge' + compress: 'true' + dest: 'dist' \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e092ecd..406ca31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,23 +3,37 @@ name: Build on: push: branches: [ "main" ] + tags: + - "v*.*.*" 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 ./... + + trigger-binaries: + needs: build-go + if: startsWith(github.ref, 'refs/tags/v') + uses: ./.github/workflows/binaries.yml + secrets: inherit + + trigger-docker-build: + needs: build-go + if: startsWith(github.ref, 'refs/tags/v') + uses: ./.github/workflows/docker.yml + secrets: inherit diff --git a/.github/workflows/build-and-push-ghcr.yml b/.github/workflows/docker.yml similarity index 63% rename from .github/workflows/build-and-push-ghcr.yml rename to .github/workflows/docker.yml index 644e98a..583242f 100644 --- a/.github/workflows/build-and-push-ghcr.yml +++ b/.github/workflows/docker.yml @@ -1,33 +1,11 @@ name: Build and Push Docker Image to GHCR on: - push: - tags: - - "v*.*.*" - workflow_dispatch: + workflow_call: jobs: - build-go: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.24' - - - name: Build - run: go build -v ./... - - - name: Test - run: go test -v ./... - build-and-push: - needs: build-go runs-on: ubuntu-latest - if: ${{ github.ref_type == 'tag' }} permissions: contents: read @@ -56,6 +34,6 @@ jobs: with: context: . push: true - tags: ghcr.io/${{ github.repository_owner }}/pulsebridge:${{ steps.extract_version.outputs.VERSION }} + tags: ghcr.io/${{ github.repository_owner }}/pulse-bridge:${{ steps.extract_version.outputs.VERSION }} cache-from: type=gha cache-to: type=gha,mode=max From 27a5a79e1ac4d4cc8c9508ff53e3cccca8832211 Mon Sep 17 00:00:00 2001 From: Shehan Chamudith Udakumbura Date: Tue, 29 Jul 2025 16:53:14 +0530 Subject: [PATCH 4/5] fix: separate workflow for release --- .github/workflows/binaries.yml | 20 --------- .github/workflows/build.yml | 12 ------ .github/workflows/{docker.yml => release.yml} | 41 +++++++++++++++++-- 3 files changed, 38 insertions(+), 35 deletions(-) delete mode 100644 .github/workflows/binaries.yml rename .github/workflows/{docker.yml => release.yml} (51%) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml deleted file mode 100644 index f5f4b30..0000000 --- a/.github/workflows/binaries.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Generate release-artifacts - -on: - workflow_call: - -jobs: - generate: - name: Generate cross-platform builds - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v2 - - name: Generate build files - uses: thatisuday/go-cross-build@v1 - with: - platforms: 'linux/amd64, darwin/amd64, windows/amd64' - package: '' - name: 'pulse-bridge' - compress: 'true' - dest: 'dist' \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 406ca31..6f3367c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,15 +25,3 @@ jobs: - name: Test run: go test -v ./... - - trigger-binaries: - needs: build-go - if: startsWith(github.ref, 'refs/tags/v') - uses: ./.github/workflows/binaries.yml - secrets: inherit - - trigger-docker-build: - needs: build-go - if: startsWith(github.ref, 'refs/tags/v') - uses: ./.github/workflows/docker.yml - secrets: inherit diff --git a/.github/workflows/docker.yml b/.github/workflows/release.yml similarity index 51% rename from .github/workflows/docker.yml rename to .github/workflows/release.yml index 583242f..bbe4a91 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,45 @@ -name: Build and Push Docker Image to GHCR +name: Release on: - workflow_call: + push: + tags: + - "v*.*.*" + workflow_dispatch: jobs: - build-and-push: + 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: From 063d663f7a7cf945637f0a4a72072ea4c7b95398 Mon Sep 17 00:00:00 2001 From: Shehan Chamudith Udakumbura Date: Tue, 29 Jul 2025 17:06:10 +0530 Subject: [PATCH 5/5] fix: remove tag trigger from build workflow --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f3367c..24350d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,7 @@ name: Build on: push: - branches: [ "main" ] - tags: - - "v*.*.*" + branches: ["main"] pull_request: branches: [ "main","*" ]