-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
258 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: ["**"] | ||
tags-ignore: ["v*"] | ||
pull_request: | ||
|
||
jobs: | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install additional build tools | ||
run: | | ||
go get golang.org/x/lint/golint | ||
make install-sys-packages | ||
- name: Test | ||
run: make test | ||
|
||
- name: Lint | ||
run: make lint | ||
|
||
- name: Build Linux | ||
run: make build-linux | ||
|
||
- name: Build Windows | ||
run: make build-windows | ||
|
||
- name: Build Centos | ||
run: make build-centos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: ["v*"] | ||
|
||
jobs: | ||
|
||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install additional build tools | ||
run: | | ||
go get golang.org/x/lint/golint | ||
make install-sys-packages | ||
- name: Build | ||
run: make build-all-optimized | ||
|
||
- name: Compress binaries | ||
run: make compress-binaries | ||
|
||
- name: Get version | ||
id: get_version | ||
run: VERSION_NUMBER=${GITHUB_RUN_NUMBER}-${GITHUB_SHA:0:7} make print-version | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ steps.get_version.outputs.version }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: snippet | ||
asset_name: snippet | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: snippet-centos | ||
asset_name: snippet-centos | ||
asset_content_type: application/octet-stream | ||
|
||
# - name: Upload Release Asset | ||
# uses: actions/upload-release-asset@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# with: | ||
# upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
# asset_path: snippet.exe | ||
# asset_name: snippet.exe | ||
# asset_content_type: application/octet-stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
snippet | ||
snippet.exe | ||
snippet-centos | ||
snippet.exe | ||
pkg_tok | ||
upx | ||
upx*.tar.xz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
BASE_VERSION=0.0.1 | ||
REPO_OWNER=sandro-h | ||
BUILD_CENTOS_IMAGE_VERSION=0.0.1 | ||
BUILD_CENTOS_IMAGE_TAG=ghcr.io/${REPO_OWNER}/snippet-centos-build:${BUILD_CENTOS_IMAGE_VERSION} | ||
PUSH_IMAGE=false | ||
|
||
|
||
.PHONY: docker-login | ||
docker-login: | ||
echo $$DOCKER_PWD | docker login ghcr.io -u ${REPO_OWNER} --password-stdin | ||
|
||
.PHONY: push-centos-image | ||
push-centos-image: | ||
ifeq ($(PUSH_IMAGE), true) | ||
docker push ${BUILD_CENTOS_IMAGE_TAG} | ||
endif | ||
|
||
.PHONY: build-centos-image | ||
build-centos-image: | ||
docker build \ | ||
--tag ${BUILD_CENTOS_IMAGE_TAG} \ | ||
centos/ | ||
|
||
.PHONY: ensure-centos-image | ||
ensure-centos-image: | ||
docker pull ${BUILD_CENTOS_IMAGE_TAG} || make build-centos-image push-centos-image | ||
|
||
.PHONY: ensure-centos-image | ||
build-centos: ensure-centos-image | ||
docker run --rm \ | ||
-v $$(pwd):/src \ | ||
-e DEV_UID=$$(id -u) \ | ||
-w /src \ | ||
${BUILD_CENTOS_IMAGE_TAG} \ | ||
"/usr/local/go/bin/go build -o snippet-centos ${EXTRA_BUILD_ARGS} && chown \$$DEV_UID snippet-centos" | ||
|
||
.PHONY: build-windows | ||
build-windows: | ||
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build ${EXTRA_BUILD_ARGS} | ||
|
||
.PHONY: build-linux | ||
build-linux: | ||
go build ${EXTRA_BUILD_ARGS} | ||
|
||
.PHONY: test | ||
test: | ||
go test ./... | ||
|
||
.PHONY: lint | ||
lint: | ||
golint -set_exit_status ./... | ||
|
||
.PHONY: install-sys-packages | ||
install-sys-packages: | ||
sudo apt install gcc libc6-dev \ | ||
libx11-dev xorg-dev libxtst-dev libpng++-dev \ | ||
xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev \ | ||
libxkbcommon-dev xsel xclip \ | ||
libgl1-mesa-dev \ | ||
gcc-mingw-w64-x86-64 libz-mingw-w64-dev | ||
|
||
########################################################################################### | ||
# Releasing | ||
########################################################################################### | ||
|
||
.PHONY: release | ||
release: | ||
git tag v${BASE_VERSION} | ||
git push origin v${BASE_VERSION} | ||
|
||
|
||
.PHONY: print-version | ||
print-version: | ||
echo "::set-output name=version::${BASE_VERSION}.$${VERSION_NUMBER:-0}" | ||
|
||
.PHONY: build-all-optimized | ||
build-all-optimized: EXTRA_BUILD_ARGS=-ldflags='-s -w' | ||
build-all-optimized: build-linux build-centos # build-windows | ||
|
||
upx: | ||
wget https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz | ||
tar xf upx-3.96-amd64_linux.tar.xz | ||
mv upx-3.96-amd64_linux/ upx | ||
|
||
.PHONY: compress-binaries | ||
compress-binaries: upx | ||
chmod +x snippet snippet-centos | ||
upx/upx -q --brute snippet | ||
upx/upx -q --brute snippet-centos | ||
# upx/upx -q --brute snippet.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM centos:7 | ||
|
||
# Basic build tools | ||
RUN yum -y install centos-release-scl | ||
RUN yum -y install devtoolset-7-gcc-c++ | ||
|
||
# golang tools | ||
RUN yum -y install wget | ||
RUN wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz | ||
RUN tar -C /usr/local -xzf go1.16.3.linux-amd64.tar.gz | ||
RUN echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc | ||
|
||
# dev libs for robotgo and fyne | ||
RUN yum -y install \ | ||
libXcursor-devel \ | ||
libXrandr-devel \ | ||
libXinerama-devel \ | ||
mesa-libGL-devel \ | ||
libXtst-devel \ | ||
libpng-devel \ | ||
libxkbcommon-x11-devel | ||
|
||
ENTRYPOINT ["scl", "enable", "devtoolset-7"] | ||
CMD ["bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters