mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
chore: update build workflow and add container build script (#70)
* chore: update build workflow and add container build script * Add build dependencies to workflow * fix: remove unnecessary magellan installation path from goreleaser config
This commit is contained in:
parent
52c7e85a5e
commit
f291ba41f9
3 changed files with 96 additions and 31 deletions
11
.github/workflows/main.yml
vendored
11
.github/workflows/main.yml
vendored
|
|
@ -22,6 +22,13 @@ jobs:
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt update && sudo apt install -y curl git gcc g++ make \
|
||||||
|
gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu \
|
||||||
|
libc6-dev-arm64-cross software-properties-common
|
||||||
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -53,6 +60,6 @@ jobs:
|
||||||
args: release --clean
|
args: release --clean
|
||||||
id: goreleaser
|
id: goreleaser
|
||||||
- name: Attest Binaries
|
- name: Attest Binaries
|
||||||
uses: actions/attest-build-provenance@v1
|
uses: actions/attest-build-provenance@v2
|
||||||
with:
|
with:
|
||||||
subject-path: '${{ github.workspace }}/dist/magellan_linux_amd64_v3/magellan'
|
subject-checksums: dist/checksums.txt
|
||||||
|
|
|
||||||
|
|
@ -27,18 +27,20 @@ builds:
|
||||||
- version
|
- version
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- darwin
|
|
||||||
- windows
|
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
- arm64
|
- arm64
|
||||||
goamd64:
|
goamd64:
|
||||||
- v3
|
- v3
|
||||||
|
goarm:
|
||||||
|
- 7
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=1
|
||||||
|
- CC={{ if eq .Arch "arm64" }}aarch64-linux-gnu-gcc{{ else }}gcc{{ end }}
|
||||||
|
- CXX={{ if eq .Arch "arm64" }}aarch64-linux-gnu-g++{{ else }}g++{{ end }}
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- format: tar.gz
|
- formats: [ 'tar.gz' ]
|
||||||
# this name template makes the OS and Arch compatible with the results of uname.
|
# this name template makes the OS and Arch compatible with the results of uname.
|
||||||
name_template: >-
|
name_template: >-
|
||||||
{{ .ProjectName }}_
|
{{ .ProjectName }}_
|
||||||
|
|
@ -67,12 +69,11 @@ nfpms:
|
||||||
section: utils
|
section: utils
|
||||||
priority: optional
|
priority: optional
|
||||||
contents:
|
contents:
|
||||||
- src: dist/magellan_{{ .Os }}_{{ if eq .Arch "amd64" }}{{ .Arch }}_{{ .Amd64 }}{{ else }}{{ .Arch }}{{ end }}/magellan
|
|
||||||
dst: /usr/local/bin/magellan
|
|
||||||
- src: magellan.1
|
- src: magellan.1
|
||||||
dst: /usr/share/man/man1/
|
dst: /usr/share/man/man1/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dockers:
|
dockers:
|
||||||
- image_templates:
|
- image_templates:
|
||||||
- &amd64_linux_image ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}-amd64
|
- &amd64_linux_image ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}-amd64
|
||||||
|
|
@ -93,7 +94,7 @@ dockers:
|
||||||
- CHANGELOG.md
|
- CHANGELOG.md
|
||||||
- README.md
|
- README.md
|
||||||
- image_templates:
|
- image_templates:
|
||||||
- &arm64v8_linux_image ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}-arm64
|
- &arm64v7_linux_image ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}-arm64
|
||||||
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}-arm64
|
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}-arm64
|
||||||
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}-arm64
|
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}-arm64
|
||||||
use: buildx
|
use: buildx
|
||||||
|
|
@ -114,25 +115,22 @@ docker_manifests:
|
||||||
- name_template: "ghcr.io/openchami/{{.ProjectName}}:latest"
|
- name_template: "ghcr.io/openchami/{{.ProjectName}}:latest"
|
||||||
image_templates:
|
image_templates:
|
||||||
- *amd64_linux_image
|
- *amd64_linux_image
|
||||||
- *arm64v8_linux_image
|
- *arm64v7_linux_image
|
||||||
|
|
||||||
- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}"
|
- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}"
|
||||||
image_templates:
|
image_templates:
|
||||||
- *amd64_linux_image
|
- *amd64_linux_image
|
||||||
- *arm64v8_linux_image
|
- *arm64v7_linux_image
|
||||||
|
|
||||||
- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}"
|
- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}"
|
||||||
image_templates:
|
image_templates:
|
||||||
- *amd64_linux_image
|
- *amd64_linux_image
|
||||||
- *arm64v8_linux_image
|
- *arm64v7_linux_image
|
||||||
|
|
||||||
- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}"
|
- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}"
|
||||||
image_templates:
|
image_templates:
|
||||||
- *amd64_linux_image
|
- *amd64_linux_image
|
||||||
- *arm64v8_linux_image
|
- *arm64v7_linux_image
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: 'checksums.txt'
|
name_template: 'checksums.txt'
|
||||||
|
|
|
||||||
60
build-in-container.sh
Normal file
60
build-in-container.sh
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script uses the latest Ubuntu 24.04 container to build the project with GoReleaser. It emulates the GitHub Actions environment as closely as possible.
|
||||||
|
# Before submitting a PR for release/build. please run this script to ensure your PR will pass the build.
|
||||||
|
|
||||||
|
# Name of the container
|
||||||
|
CONTAINER_NAME="goreleaser-build"
|
||||||
|
|
||||||
|
# Directory where built binaries will be available
|
||||||
|
OUTPUT_DIR="$(pwd)/dist"
|
||||||
|
|
||||||
|
export GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)
|
||||||
|
export BUILD_HOST=$(hostname)
|
||||||
|
export GO_VERSION=$(go version | awk '{print $3}')
|
||||||
|
export BUILD_USER=$(whoami)
|
||||||
|
|
||||||
|
# Start a new disposable Ubuntu 24.04 container with the current directory mounted
|
||||||
|
${CONTAINER_CMD:-docker} run --rm -it \
|
||||||
|
--name "$CONTAINER_NAME" \
|
||||||
|
-v "$(pwd)":/workspace \
|
||||||
|
-w /workspace \
|
||||||
|
ubuntu:24.04 bash -c "
|
||||||
|
|
||||||
|
# Suppress timezone prompts
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
export TZ=UTC
|
||||||
|
|
||||||
|
|
||||||
|
# Update package lists and install dependencies
|
||||||
|
apt update && apt install -y curl git gcc g++ make \
|
||||||
|
gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu \
|
||||||
|
libc6-dev-arm64-cross software-properties-common
|
||||||
|
|
||||||
|
# Install Go (match GitHub runner version)
|
||||||
|
curl -fsSL https://golang.org/dl/go1.21.5.linux-amd64.tar.gz | tar -C /usr/local -xz
|
||||||
|
export PATH=\$PATH:/usr/local/go/bin
|
||||||
|
go version # Verify Go installation
|
||||||
|
|
||||||
|
# Set GOPATH and update PATH to include Go binaries
|
||||||
|
export GOPATH=\$(go env GOPATH)
|
||||||
|
export PATH=\$PATH:\$GOPATH/bin
|
||||||
|
echo \"GOPATH: \$GOPATH\" && echo \"PATH: \$PATH\"``
|
||||||
|
|
||||||
|
# Install Goreleaser
|
||||||
|
curl -sL https://github.com/goreleaser/goreleaser/releases/latest/download/goreleaser_Linux_x86_64.tar.gz | tar -xz -C /usr/local/bin
|
||||||
|
goreleaser --version # Verify Goreleaser installation
|
||||||
|
|
||||||
|
# Set Build Environment Variables
|
||||||
|
export GIT_STATE="$GIT_STATE"
|
||||||
|
export BUILD_HOST="$BUILD_HOST"
|
||||||
|
export BUILD_USER="$BUILD_USER"
|
||||||
|
export GO_VERSION=$(go version | awk '{print $3}')
|
||||||
|
|
||||||
|
# Run Goreleaser
|
||||||
|
goreleaser build --snapshot --clean
|
||||||
|
"
|
||||||
|
|
||||||
|
# Notify user of success
|
||||||
|
echo "✅ Build complete! Check the output in: $OUTPUT_DIR"
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue