Skip to content

Commit

Permalink
Merge pull request #45 from STNS/arm
Browse files Browse the repository at this point in the history
support arm
  • Loading branch information
pyama86 authored Mar 12, 2024
2 parents c219b7f + e6bb8cc commit 8c53322
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 3,198 deletions.
22 changes: 5 additions & 17 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,12 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build
run: go build -v .

Expand Down
22 changes: 6 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,17 @@ on:
tags:
- 'v*'
workflow_dispatch:
env:
COMPOSE_FILE: docker-compose.yaml
name: Release
jobs:
build:
release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
fetch-depth: 0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: build
run: make pkg
- name: donwload ghr
run: |
curl -L -O -s https://github.com/tcnksm/ghr/releases/download/v0.16.0/ghr_v0.16.0_linux_amd64.tar.gz
tar zxf ghr_v0.16.0_linux_amd64.tar.gz
sudo mv ghr_v0.16.0_linux_amd64/ghr /usr/bin
go-version-file: 'go.mod'
- name: release
run: make github_release
run: make release
40 changes: 40 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
builds:
- id: "cache-stnsd"
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
binary: "cache-stnsd"
ldflags:
- -s -w -X github.com/stns/cache-stnsd/cmd.version={{.Version}}

nfpms:
-
id: cache-stnsd-nfpms
file_name_template: "{{ .ProjectName }}_{{ .Version }}-1_{{ .Arch }}"
builds:
- cache-stnsd
homepage: https://github.com/STNS/cache-stnsd
maintainer: pyama86 <www.kazu.com@gmail.com>
description: cache daemon for STNS
license: MIT
formats:
- deb
- rpm
bindir: /usr/bin
contents:
- src: ./package/cache-stnsd.service
dst: /etc/systemd/system/cache-stnsd.service
type: config
- src: ./package/cache-stnsd.logrotate
dst: /etc//logrotate.d/cache-stnsd
type: config
epoch: 1

release:
github:
owner: STNS
name: cache-stnsd
80 changes: 8 additions & 72 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ UNAME_S := $(shell uname -s)
.DEFAULT_GOAL := build

GOPATH ?= /go
GOOS=linux
GOARCH=amd64
GO=GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go
GO=CGO_ENABLED=0 go

.PHONY: build
## build: build the nke
Expand Down Expand Up @@ -52,11 +50,15 @@ git-semv:

.PHONY: goreleaser
goreleaser:
brew install goreleaser/tap/goreleaser
brew install goreleaser
test -e goreleaser > /dev/null || curl -sfL https://goreleaser.com/static/run | bash

.PHONY: tidy
tidy:
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Tidying up$(RESET)"
$(GO) mod tidy

.PHONY: test
test:
test: tidy
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Testing$(RESET)"
$(GO) test -v $(TEST) -timeout=30s -parallel=4
CGO_ENABLED=1 go test -race $(TEST)
Expand All @@ -73,69 +75,3 @@ integration: ## Run integration test after Server wakeup
./misc/server start
$(GO) test $(VERBOSE) -integration $(TEST) $(TEST_OPTIONS)
./misc/server stop || true

.PHONY: source_for_rpm
source_for_rpm: ## Create source for RPM
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Distributing$(RESET)"
rm -rf tmp.$(DIST) cache-stnsd-$(VERSION).tar.gz
mkdir -p tmp.$(DIST)/cache-stnsd-$(VERSION)
cp -r $(SOURCES) tmp.$(DIST)/cache-stnsd-$(VERSION)
mkdir -p tmp.$(DIST)/cache-stnsd-$(VERSION)/tmp/bin
cp -r tmp/bin/* tmp.$(DIST)/cache-stnsd-$(VERSION)/tmp/bin
cd tmp.$(DIST) && \
tar cf cache-stnsd-$(VERSION).tar cache-stnsd-$(VERSION) && \
gzip -9 cache-stnsd-$(VERSION).tar
cp tmp.$(DIST)/cache-stnsd-$(VERSION).tar.gz ./builds
rm -rf tmp.$(DIST)

.PHONY: rpm
rpm: source_for_rpm ## Packaging for RPM
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Packaging for RPM$(RESET)"
cp builds/cache-stnsd-$(VERSION).tar.gz /root/rpmbuild/SOURCES
spectool -g -R rpm/cache-stnsd.spec
rpmbuild -ba rpm/cache-stnsd.spec
cp /root/rpmbuild/RPMS/*/*.rpm /go/src/github.com/STNS/cache-stnsd/builds


.PHONY: pkg
SUPPORTOS=centos7 almalinux9 ubuntu20 ubuntu22 debian10 debian11
pkg: build ## Create some distribution packages
rm -rf builds && mkdir builds
for i in $(SUPPORTOS); do \
docker-compose build cache_$$i || exit 1; \
docker-compose run -v `pwd`:/go/src/github.com/STNS/cache-stnsd -v ~/pkg:/go/pkg --rm cache_$$i || exit 1; \
done


.PHONY: source_for_deb
source_for_deb: ## Create source for DEB
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Distributing$(RESET)"
rm -rf tmp.$(DIST) cache-stnsd-$(VERSION).orig.tar.gz
mkdir -p tmp.$(DIST)/cache-stnsd-$(VERSION)
cp -r $(SOURCES) tmp.$(DIST)/cache-stnsd-$(VERSION)
mkdir -p tmp.$(DIST)/cache-stnsd-$(VERSION)/tmp/bin
cp -r tmp/bin/* tmp.$(DIST)/cache-stnsd-$(VERSION)/tmp/bin
cd tmp.$(DIST) && \
tar zcf cache-stnsd-$(VERSION).tar.gz cache-stnsd-$(VERSION)
mv tmp.$(DIST)/cache-stnsd-$(VERSION).tar.gz tmp.$(DIST)/cache-stnsd-$(VERSION).orig.tar.gz

.PHONY: deb
deb: source_for_deb ## Packaging for DEB
@echo "$(INFO_COLOR)==> $(RESET)$(BOLD)Packaging for DEB$(RESET)"
cd tmp.$(DIST) && \
tar xf cache-stnsd-$(VERSION).orig.tar.gz && \
cd cache-stnsd-$(VERSION) && \
dh_make --single --createorig -y && \
rm -rf debian/*.ex debian/*.EX debian/README.Debian && \
cp -r $(GOPATH)/src/github.com/STNS/cache-stnsd/debian/* debian/ && \
sed -i -e 's/xenial/$(DIST)/g' debian/changelog && \
debuild -uc -us
cd tmp.$(DIST) && \
find . -name "*.deb" | sed -e 's/\(\(.*cache-stnsd.*\).deb\)/mv \1 \2.$(DIST).deb/g' | sh && \
mkdir -p $(GOPATH)/src/github.com/STNS/cache-stnsd/builds && \
cp *.deb $(GOPATH)/src/github.com/STNS/cache-stnsd/builds
rm -rf tmp.$(DIST)

.PHONY: github_release
github_release: ## Create some distribution packages
ghr -u STNS --replace v$(VERSION) builds/
91 changes: 0 additions & 91 deletions debian/changelog

This file was deleted.

1 change: 0 additions & 1 deletion debian/compat

This file was deleted.

14 changes: 0 additions & 14 deletions debian/control

This file was deleted.

25 changes: 0 additions & 25 deletions debian/copyright

This file was deleted.

3 changes: 0 additions & 3 deletions debian/dirs

This file was deleted.

53 changes: 0 additions & 53 deletions debian/postinst

This file was deleted.

Loading

0 comments on commit 8c53322

Please sign in to comment.