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

Release amd64 and arm64 versions #25

Merged
merged 4 commits into from
Aug 1, 2024
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
12 changes: 10 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ jobs:
name: Build
runs-on: ubuntu-latest

strategy:
matrix:
os:
- linux
arch:
- amd64
- arm64

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -52,7 +60,7 @@ jobs:

- name: Build project
run: |
make release
make release GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }}

- name: Upload image tarballs to GCS
run: |
Expand All @@ -66,5 +74,5 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
bin/nftables-exporter*
nftables-exporter.tgz
nftables-exporter*.tgz
if: ${{ github.event_name == 'release' }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
vendor
bin
nftables-exporter.tgz
rel
nftables-exporter*.tgz
nft.json
rules.json

Expand Down
28 changes: 18 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,43 @@ VERSION := $(or ${GITHUB_TAG_NAME},$(shell git describe --tags --exact-match 2>

GOFILES=$(wildcard *.go)
GONAME=$(shell basename "$(PWD)")
GOOS := linux
GOARCH := amd64
BINARY := $(GONAME)-$(GOOS)-$(GOARCH)

all:
build:
go build \
-trimpath \
-tags netgo \
-ldflags "-X 'github.com/metal-stack/v.Version=$(VERSION)' \
-X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \
-X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \
-X 'github.com/metal-stack/v.BuildDate=$(BUILDDATE)'" \
-o bin/$(GONAME) $(GOFILES)
strip bin/$(GONAME)
sha256sum bin/$(GONAME) > bin/$(GONAME).sha256
-o bin/$(BINARY) $(GOFILES)
strip bin/$(BINARY)
sha256sum bin/$(BINARY) > bin/$(BINARY).sha256


run: all
run:
$(MAKE) build BINARY=$(GONAME)-dev
go run $(GOFILES) --config=$(shell pwd)/nftables_exporter.yaml

clean:
@echo "Cleaning"
go clean

##
# Release
##

.PHONY: release
release: all
release: build
rm -rf rel
rm -f nftables-exporter.tgz
mkdir -p rel/usr/bin rel/etc/systemd/system
cp bin/nftables-exporter rel/usr/bin
cp bin/nftables-exporter-$(GOOS)-$(GOARCH) rel/usr/bin/nftables-exporter
cp systemd/nftables-exporter.service rel/etc/systemd/system
cd rel \
&& tar -cvzf nftables-exporter.tgz usr/bin/nftables-exporter etc/systemd/system/nftables-exporter.service \
&& mv nftables-exporter.tgz .. \
&& tar --transform="flags=r;s|-$(GOOS)-$(GOARCH)||" -cvzf nftables-exporter-$(GOOS)-$(GOARCH).tgz \
usr/bin/nftables-exporter etc/systemd/system/nftables-exporter.service \
&& mv nftables-exporter-$(GOOS)-$(GOARCH).tgz .. \
&& cd -
19 changes: 0 additions & 19 deletions rel/etc/systemd/system/nftables-exporter.service

This file was deleted.

Loading