Skip to content

Commit

Permalink
add project files
Browse files Browse the repository at this point in the history
Signed-off-by: (╯°□°)╯︵ uᴉǝssnH ɐɟɐʇsoW <[email protected]>
  • Loading branch information
mostafahussein committed Dec 5, 2022
1 parent 438280c commit b871f12
Show file tree
Hide file tree
Showing 27 changed files with 1,817 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: build
on:
push:
branches-ignore:
- 'v**'
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
submodules: 'true'
- run: git fetch --prune --unshallow
- name: setup dependencies
uses: actions/setup-go@v2
- name: build
run: make build
23 changes: 23 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release
on:
push:
tags:
- v*
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
submodules: 'true'
- run: git fetch --prune --unshallow
- name: setup dependencies
uses: actions/setup-go@v2
- name: release dry run
run: make release-dry-run
- name: setup release environment
run: |-
echo 'GITHUB_TOKEN=${{secrets.GORELEASER_ACCESS_TOKEN}}' > .release-env
- name: release publish
run: make release
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*.exe
*.exe~
*.dll
*.so
*.dylib

*.test

*.out

go.work

.idea/*

dist/

.release-env
110 changes: 110 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
before:
hooks:
- go mod tidy
builds:
- id: darwin-amd64
main: ./
binary: conceal
goos:
- darwin
goarch:
- amd64
env:
- PKG_CONFIG_SYSROOT_DIR=/sysroot/macos/amd64
- PKG_CONFIG_PATH=/sysroot/macos/amd64/usr/local/lib/pkgconfig
- CC=o64-clang
- CXX=o64-clang++
flags:
- -mod=readonly
ldflags:
- -s -w -X conceal/internal/config.Version={{.Version}}
- id: darwin-arm64
main: ./
binary: conceal
goos:
- darwin
goarch:
- arm64
env:
- PKG_CONFIG_SYSROOT_DIR=/sysroot/macos/arm64
- PKG_CONFIG_PATH=/sysroot/macos/arm64/usr/local/lib/pkgconfig
- CC=o64-clang
- CXX=o64-clang++
flags:
- -mod=readonly
ldflags:
- -s -w -X conceal/internal/config.Version={{.Version}}
- id: linux-amd64
main: ./
binary: conceal
goos:
- linux
goarch:
- amd64
env:
- PKG_CONFIG_SYSROOT_DIR=/sysroot/linux/amd64
- PKG_CONFIG_PATH=/sysroot/linux/amd64/usr/local/lib/pkgconfig
- CC=gcc
- CXX=g++
flags:
- -mod=readonly
ldflags:
- -s -w -X conceal/internal/config.Version={{.Version}}
- id: linux-arm64
main: ./
binary: conceal
goos:
- linux
goarch:
- arm64
env:
- PKG_CONFIG_SYSROOT_DIR=/sysroot/linux/arm64
- PKG_CONFIG_PATH=/sysroot/linux/arm64/usr/local/lib/pkgconfig
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
flags:
- -mod=readonly
ldflags:
- -s -w -X conceal/internal/config.Version={{.Version}}
- id: linux-armhf
main: ./
binary: conceal
goos:
- linux
goarch:
- arm
goarm:
- 7
env:
- CC=arm-linux-gnueabihf-gcc
- CXX=arm-linux-gnueabihf-g++
- CGO_CFLAGS=--sysroot=/sysroot/linux/armhf
- CGO_LDFLAGS=--sysroot=/sysroot/linux/armhf
- PKG_CONFIG_SYSROOT_DIR=/sysroot/linux/armhf
- PKG_CONFIG_PATH=/sysroot/linux/armhf/opt/vc/lib/pkgconfig:/sysroot/linux/armhf/usr/lib/arm-linux-gnueabihf/pkgconfig:/sysroot/linux/armhf/usr/lib/pkgconfig:/sysroot/linux/armhf/usr/local/lib/pkgconfig
flags:
- -mod=readonly
ldflags:
- -s -w -X conceal/internal/config.Version={{.Version}}
archives:
- id: conceal
builds:
- darwin-amd64
- darwin-arm64
- linux-amd64
- linux-arm64
- linux-armhf
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
format: binary
wrap_in_directory: true
files: []
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2022 Mostafa Hussein

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
PACKAGE_NAME := github.com/conceal-cli/cli
GOLANG_CROSS_VERSION ?= v1.19.3

SYSROOT_DIR ?= sysroots
SYSROOT_ARCHIVE ?= sysroots.tar.bz2

.PHONY: sysroot-pack
sysroot-pack:
@tar cf - $(SYSROOT_DIR) -P | pv -s $[$(du -sk $(SYSROOT_DIR) | awk '{print $1}') * 1024] | pbzip2 > $(SYSROOT_ARCHIVE)

.PHONY: sysroot-unpack
sysroot-unpack:
@pv $(SYSROOT_ARCHIVE) | pbzip2 -cd | tar -xf -

.PHONY: build
build:
@docker run \
--rm \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish --snapshot

.PHONY: release-dry-run
release-dry-run:
@docker run \
--rm \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish

.PHONY: release
release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
docker run \
--rm \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v `pwd`/sysroot:/sysroot \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --rm-dist
Loading

0 comments on commit b871f12

Please sign in to comment.