Skip to content
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

refactor: Update Go version #66

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 22 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,36 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.21
- name: Set up latest stable Go
uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: stable

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: 1
fetch-depth: 1

# Set environment variables required by GoReleaser
- name: Set build environment variables
run: |
echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV
echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV

- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: 1
fetch-depth: 0

- name: Release with goreleaser
uses: goreleaser/goreleaser-action@v6
env:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/prbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build PR with goreleaser

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, edited]
workflow_dispatch:

jobs:
prbuild:
runs-on: ubuntu-latest
steps:

- name: Set up latest stable Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: 1
fetch-depth: 1

# Set environment variables required by GoReleaser
- name: Set build environment variables
run: |
echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV
echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV

- name: Build with goreleaser
uses: goreleaser/goreleaser-action@v6

with:
version: '~> v2'
args: release --snapshot
id: goreleaser
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ emulator/rf-emulator
**.part
dist/*
**coverage.out**
magellan.1
109 changes: 94 additions & 15 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,33 @@ before:
- go-md2man -in README.md -out magellan.1

builds:
- env:
- CGO_ENABLED=1
- binary: magellan
# 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)
ldflags:
- "-X main.GitCommit={{.Commit}} \
-X main.BuildTime={{.Timestamp}} \
-X main.Version={{.Version}} \
-X main.GitBranch={{.Branch}} \
-X main.GitTag={{.Tag}} \
-X main.GitState={{ .Env.GIT_STATE }} \
-X main.BuildHost={{ .Env.BUILD_HOST }} \
-X main.GoVersion={{ .Env.GO_VERSION }} \
-X main.BuildUser={{ .Env.BUILD_USER }} "
goos:
- linux
- darwin
- windows
davidallendj marked this conversation as resolved.
Show resolved Hide resolved
goarch:
- amd64
- arm64
goamd64:
- v3
env:
- CGO_ENABLED=0

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
Expand All @@ -27,26 +48,89 @@ archives:
- LICENSE
- CHANGELOG.md
- README.md
- bin/magellan.sh
- magellan.1

nfpms:
- id: magellan
formats:
- deb
- rpm
- apk
- archlinux
maintainer: "David J. Allen <allend@lanl.gov>"
description: "Magellan is a discovery tool for BMCs."
homepage: "https://www.openchami.org"
license: MIT
section: utils
priority: optional
contents:
- src: dist/magellan_{{ .Os }}_{{ if eq .Arch "amd64" }}{{ .Arch }}_{{ .Amd64 }}{{ else }}{{ .Arch }}{{ end }}/magellan
dst: /usr/local/bin/magellan
- src: magellan.1
dst: /usr/share/man/man1/


dockers:
-
image_templates:
- ghcr.io/openchami/{{.ProjectName}}:latest
- ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}
- ghcr.io/openchami/{{.ProjectName}}:v{{ .Major }}
- ghcr.io/openchami/{{.ProjectName}}:v{{ .Major }}.{{ .Minor }}
- image_templates:
- &amd64_linux_image ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}-amd64
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}-amd64
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}-amd64
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
goarch: amd64
goamd64: v3
extra_files:
- LICENSE
- CHANGELOG.md
- README.md
- bin/magellan.sh
- image_templates:
- &arm64v8_linux_image ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}-arm64
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}-arm64
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}-arm64
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
extra_files:
- LICENSE
- CHANGELOG.md
- README.md
goarch: arm64

docker_manifests:
- name_template: "ghcr.io/openchami/{{.ProjectName}}:latest"
image_templates:
- *amd64_linux_image
- *arm64v8_linux_image

- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}"
image_templates:
- *amd64_linux_image
- *arm64v8_linux_image

- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}"
image_templates:
- *amd64_linux_image
- *arm64v8_linux_image

- name_template: "ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}"
image_templates:
- *amd64_linux_image
- *arm64v8_linux_image




checksum:
name_template: 'checksums.txt'
snapshot:
Expand All @@ -57,8 +141,3 @@ changelog:
exclude:
- '^docs:'
- '^test:'
release:
github:
name_template: "{{.Version}}"
prerelease: auto
mode: append
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
FROM cgr.dev/chainguard/wolfi-base
FROM chainguard/wolfi-base:latest

RUN apk add --no-cache tini bash
# Include curl in the final image for manual checks of the Redfish urls
RUN set -ex \
&& apk update \
&& apk add --no-cache curl tini \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/*

# nobody 65534:65534
USER 65534:65534


COPY magellan /magellan
COPY /bin/magellan.sh /magellan.sh


CMD [ "/magellan" ]
Expand Down
122 changes: 0 additions & 122 deletions bin/magellan.sh

This file was deleted.

Loading
Loading