Skip to content

Commit

Permalink
Release amd64 and arm64 versions (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
orblazer authored Aug 1, 2024
1 parent b5361c8 commit 1419111
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
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.

0 comments on commit 1419111

Please sign in to comment.