This directory contains the CI/CD workflows for the CloudAMQP CLI.
Runs on every push to main or develop branches, and on pull requests.
What it does:
- Tests with multiple Go versions (1.21, 1.22, 1.23)
- Runs format checks, vet, and tests
- Builds the binary with version information
- Uploads test coverage to Codecov
- Verifies the binary works with
--helpandversioncommands
Version Information: The CI build automatically includes:
- Version: From
git describe --tags --always --dirty(or "dev" as fallback) - Build Date: Current date in UTC (YYYY-MM-DD)
- Git Commit: Short commit hash
Triggers when a tag starting with v is pushed (e.g., v1.0.0), or can be run manually.
What it does:
-
Build Job: Builds cross-platform binaries for:
- Linux (amd64, arm64)
- macOS (amd64, arm64)
- Windows (amd64, arm64)
-
Package Job: Creates release archives:
.tar.gzfor Linux/macOS binaries.zipfor Windows binaries- Creates GitHub Release with all artifacts
Version Information: Release builds automatically include:
- Version: From the git tag (e.g.,
v1.0.0) - Build Date: Current date in UTC (YYYY-MM-DD)
- Git Commit: Short commit hash
The version info is embedded using Go's -ldflags:
-ldflags="-w -s -X cloudamqp-cli/cmd.Version=$VERSION -X cloudamqp-cli/cmd.BuildDate=$BUILD_DATE -X cloudamqp-cli/cmd.GitCommit=$GIT_COMMIT"To create a new release:
-
Create and push a tag:
git tag v1.0.0 git push origin v1.0.0
-
The release workflow will automatically:
- Build binaries for all platforms
- Create archives
- Create a GitHub release with auto-generated release notes
- Upload all artifacts
-
The released binaries will show proper version info:
$ cloudamqp version cloudamqp version v1.0.0 (2025-11-26) https://github.com/cloudamqp/cli/releases/tag/v1.0.0
The release workflow can also be triggered manually from the GitHub Actions UI:
- Go to Actions tab
- Select "Build Release" workflow
- Click "Run workflow"
- Select branch and click "Run workflow"
Both workflows include verification steps:
- CI: Tests the built binary with
--helpandversioncommands - Release: Attempts to run
versioncommand on non-Windows binaries (may skip for cross-compiled binaries)
Both workflows use Go module caching to speed up builds:
- Cache key includes Go version and
go.sumhash - Cached paths:
~/.cache/go-buildand~/go/pkg/mod
CI builds:
- Standard build flags
- Version information included
Release builds:
-a: Force rebuilding of packages-installsuffix cgo: Use suffix for cgo-enabled builds-ldflags="-w -s": Strip debug info and symbol tables (smaller binaries)- Version information via
-Xflags CGO_ENABLED=0: Disable cgo for static binaries
CI Workflow:
- Uploads test coverage to Codecov
Release Workflow:
- Individual binaries (30 days retention)
- Release archives (90 days retention)
- GitHub Release assets (permanent)
If version information is not showing correctly in releases:
- Check that tags are pushed:
git push origin --tags - Verify tag format: Must start with
v(e.g.,v1.0.0) - Check workflow logs for version extraction step
- Ensure no local modifications (avoid
-dirtyin version)
To test version embedding locally:
# Using Make (recommended)
make build
# Manual
VERSION=v1.0.0
BUILD_DATE=$(date -u +"%Y-%m-%d")
GIT_COMMIT=$(git rev-parse --short HEAD)
go build -ldflags "\
-X cloudamqp-cli/cmd.Version=$VERSION \
-X cloudamqp-cli/cmd.BuildDate=$BUILD_DATE \
-X cloudamqp-cli/cmd.GitCommit=$GIT_COMMIT" \
-o cloudamqp .