Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
@@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can actually copy that script here and simply run it as i did with the project

package: ''
name: 'pulse-bridge'
compress: 'true'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not compress

dest: 'dist'
34 changes: 24 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-binaries

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not build and release for cross platforms with the build.yml

we should maintain two workflows

  1. build.yml for building for anything like main, prs or a tag push
  2. release.yml - triggers only for a tag push

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
39 changes: 39 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Push Docker Image to GHCR

on:
workflow_call:

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 }}/pulse-bridge:${{ steps.extract_version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max