Skip to content

Commit

Permalink
fix(github): more dynamic makefile build
Browse files Browse the repository at this point in the history
  • Loading branch information
ikr4-m committed Jan 10, 2025
1 parent 9c60ae6 commit 2312b2d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/build-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ jobs:
make_command: [build-client, build-tunnel]
include:
- make_command: build-client
binary_name: mdrop-linux-amd64
binary_name: mdrop
binary_os: linux
binary_arch: amd64
- make_command: build-tunnel
binary_name: mdrop-tunnel
binary_os: linux
binary_arch: amd64
uses: ./.github/workflows/reusable-build-golang-alpine.yml
with:
make_command: ${{ matrix.make_command }}
Expand All @@ -37,6 +41,14 @@ jobs:
needs: [artifact-build]
strategy:
matrix:
binary_name: [build-client, build-tunnel]
include:
- binary_name: mdrop
binary_os: linux
binary_arch: amd64
- binary_name: mdrop-tunnel
binary_os: linux
binary_arch: amd64
binary_name:
- mdrop-linux-amd64
- mdrop-tunnel
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/reusable-build-golang-alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ on:
binary_name:
type: string
default: mdrop
binary_os:
type: string
default: linux
binary_arch:
type: string
default: amd64

jobs:
build:
Expand All @@ -28,10 +34,10 @@ jobs:
apk update
apk add make gcc musl-dev
- name: Build app
run: make ${{ inputs.make_command }}
run: make BINARY_SUFFIX=-${{ inputs.binary_os }}-${{ inputs.binary_arch }} ${{ inputs.make_command }}
- name: Upload artifacts
if: ${{ inputs.use_artifacts }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.binary_name }}-build-artifact-${{ github.sha }}
path: ./${{ inputs.binary_name }}
name: ${{ inputs.binary_name }}-${{ inputs.binary_os }}-${{ inputs.binary_arch }}-artifact
path: ./${{ inputs.binary_name }}-${{ inputs.binary_os }}-${{ inputs.binary_arch }}
8 changes: 7 additions & 1 deletion .github/workflows/reusable-upload-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ on:
binary_name:
type: string
default: mdrop
binary_os:
type: string
default: linux
binary_arch:
type: string
default: amd64

jobs:
upload:
Expand All @@ -23,7 +29,7 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ inputs.binary_name }}-build-artifact-${{ github.sha }}
name: ${{ inputs.binary_name }}-${{ inputs.binary_os }}-${{ inputs.binary_arch }}-artifact
- name: Check file
run: |
pwd
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
BINARY_SUFFIX ?= ""

restore:
go get -C ./cmd/mdrop-client
go get -C ./cmd/mdrop-tunnel-tools
go get -C ./internal

build-client: restore
go build -C ./cmd/mdrop-client -ldflags="-linkmode external -extldflags -static -w -s" -o "../../mdrop"
go build -C ./cmd/mdrop-client -ldflags="-linkmode external -extldflags -static -w -s" -o "../../mdrop${BINARY_SUFFIX}"

build-tunnel: restore
go build -C ./cmd/mdrop-tunnel-tools -ldflags="-linkmode external -extldflags -static -w -s" -o "../../mdrop-tunnel"

build-client-general: restore
go build -C ./cmd/mdrop-client -ldflags="-extldflags -static -w -s" -o "../../mdrop"
go build -C ./cmd/mdrop-client -ldflags="-extldflags -static -w -s" -o "../../mdrop${BINARY_SUFFIX}"

build-tunnel-general: restore
go build -C ./cmd/mdrop-tunnel-tools -ldflags="-extldflags -static -w -s" -o "../../mdrop-tunnel"

0 comments on commit 2312b2d

Please sign in to comment.