Skip to content

PMM-7: Fix disabled CGO_ENABLED in release builds #1142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build

on:
push:
branches:
- main
- release-0.1x
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:

permissions:
contents: read

jobs:
build:
name: Build

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: ${{ github.workspace }}/go.mod

- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1

- name: Dry-run GoReleaser
run: |
make release-dry-run
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
echo "--- Environment variables ---"
env | sort
echo "--- GO Environment ---"
go env | sort
echo "--- Git status ---"
git status
echo "--- Docker logs ---"
docker compose logs
echo "--- Docker ps ---"
docker compose ps -a
File renamed without changes.
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ builds:
- binary: mongodb_exporter
id: mongodb_exporter
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
Expand Down
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all build clean default help init test format check-license
.PHONY: all build clean default help init test format check-license release-dry-run
default: help

GO_TEST_PATH ?= ./...
Expand Down Expand Up @@ -83,6 +83,21 @@ release: ## Build the binaries using goreleaser
-w /go/src/github.com/user/repo \
goreleaser/goreleaser release --snapshot --skip=publish --clean

release-dry-run: ## Build cross-platform binaries locally without publishing
@echo "Building cross-platform binaries with GoReleaser..."
@if command -v goreleaser >/dev/null 2>&1; then \
goreleaser build --snapshot --clean; \
else \
echo "GoReleaser not found. Installing via Docker..."; \
docker run --rm --privileged \
-v ${PWD}:/go/src/github.com/percona/mongodb_exporter \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/percona/mongodb_exporter \
goreleaser/goreleaser build --snapshot --clean; \
fi
@find build -name mongodb_exporter -type f | sort


FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")

format: ## Format source code
Expand Down
Loading