forked from ms/transocks
This commit is contained in:
parent
a59ad95f63
commit
8dd4b1a7d9
@ -10,7 +10,7 @@ on:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: check-out
|
||||
@ -41,7 +41,7 @@ jobs:
|
||||
version: v1.60
|
||||
|
||||
- name: build amd64
|
||||
id: build-amd
|
||||
id: build-amd64
|
||||
run: |
|
||||
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-amd64" >> $GITHUB_OUTPUT
|
||||
GOARCH=amd64 make clean build
|
||||
@ -49,12 +49,12 @@ jobs:
|
||||
- name: upload amd64
|
||||
uses: https://gitea.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ steps.build-amd.outputs.ARTIFACT }}
|
||||
name: ${{ steps.build-amd64.outputs.ARTIFACT }}
|
||||
path: out/bin/*
|
||||
overwrite: true
|
||||
|
||||
- name: build arm64
|
||||
id: build-arm
|
||||
id: build-arm64
|
||||
run: |
|
||||
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-arm64" >> $GITHUB_OUTPUT
|
||||
GOARCH=arm64 make clean build
|
||||
@ -62,47 +62,6 @@ jobs:
|
||||
- name: upload arm64
|
||||
uses: https://gitea.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ steps.build-arm.outputs.ARTIFACT }}
|
||||
path: out/bin/*
|
||||
overwrite: true
|
||||
|
||||
build_windows:
|
||||
runs-on: windows
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: check-out
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: set-up dependencies
|
||||
run: make vendor
|
||||
|
||||
- name: build amd
|
||||
id: build-amd
|
||||
run: |
|
||||
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-amd64" >> $GITHUB_OUTPUT
|
||||
GOARCH=amd64 make build
|
||||
|
||||
- name: upload amd
|
||||
uses: https://gitea.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ steps.build-amd.outputs.ARTIFACT }}
|
||||
path: out/bin/*
|
||||
overwrite: true
|
||||
|
||||
- name: build arm
|
||||
id: build-arm
|
||||
run: |
|
||||
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-arm64" >> $GITHUB_OUTPUT
|
||||
GOARCH=arm64 make build
|
||||
|
||||
- name: upload amd
|
||||
uses: https://gitea.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ steps.build-arm.outputs.ARTIFACT }}
|
||||
name: ${{ steps.build-arm64.outputs.ARTIFACT }}
|
||||
path: out/bin/*
|
||||
overwrite: true
|
||||
|
@ -1,13 +1,20 @@
|
||||
name: release
|
||||
|
||||
run-name: ${{ gitea.actor }} release Transocks
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.meta.outputs.VERSION }}
|
||||
changes: ${{ steps.meta.outputs.CHANGES }}
|
||||
artifact_amd64: ${{ steps.build-amd.outputs.ARTIFACT }}
|
||||
artifact_arm64: ${{ steps.build-arm.outputs.ARTIFACT }}
|
||||
steps:
|
||||
- name: check-out
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
@ -15,42 +22,124 @@ jobs:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: set-up qemu
|
||||
uses: https://git.mousesoft.ru/ms/gitea-action-setup-qemu@v3
|
||||
|
||||
- name: set-up docker buildx
|
||||
uses: https://git.mousesoft.ru/ms/gitea-action-docker-setup-buildx@v3
|
||||
- name: set-up go
|
||||
uses: https://gitea.com/actions/setup-go@v3
|
||||
with:
|
||||
buildkitd-flags: --debug
|
||||
|
||||
- name: login to docker hub
|
||||
uses: https://git.mousesoft.ru/ms/gitea-action-docker-login@v3
|
||||
with:
|
||||
registry: git.mousesoft.ru
|
||||
username: ${{ secrets.API_USER }}
|
||||
password: ${{ secrets.API_TOKEN }}
|
||||
go-version: ">=1.22"
|
||||
|
||||
- name: meta
|
||||
id: meta
|
||||
env:
|
||||
SSH_HOST: ${{ secrets.DEB_SSH_HOST }}
|
||||
run: |
|
||||
echo IMAGE_CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | tee -a $GITHUB_OUTPUT
|
||||
echo IMAGE_VERSION=$(./version.sh n) | tee -a $GITHUB_OUTPUT
|
||||
echo IMAGE_REVISION=$(git rev-parse HEAD) | tee -a $GITHUB_OUTPUT
|
||||
echo "VERSION=$(make version)" >> $GITHUB_OUTPUT
|
||||
echo 'CHANGES<<EOF' >> $GITHUB_OUTPUT
|
||||
gawk -f scripts/changes.awk -v version=$(make version-number) CHANGELOG.md >> $GITHUB_OUTPUT
|
||||
echo EOF >> $GITHUB_OUTPUT
|
||||
mkdir -p out
|
||||
sed -e "s/DEB_SSH_HOST/$SSH_HOST/g" deploy/dput/mousesoft.json.tpl > out/mousesoft.json
|
||||
|
||||
- name: build and push
|
||||
uses: https://git.mousesoft.ru/ms/gitea-action-docker-build-push@v6
|
||||
- name: upload dput profile
|
||||
uses: https://gitea.com/actions/upload-artifact@v3
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64
|
||||
pull: true
|
||||
push: true
|
||||
no-cache: true
|
||||
build-args: |
|
||||
IMAGE_VERSION=${{ steps.meta.outputs.IMAGE_VERSION }}
|
||||
IMAGE_CREATED=${{ steps.meta.outputs.IMAGE_CREATED }}
|
||||
tags: |
|
||||
git.mousesoft.ru/alexey/transocks:${{ steps.meta.outputs.IMAGE_VERSION }}
|
||||
git.mousesoft.ru/alexey/transocks:latest
|
||||
name: mousesoft_dput_profile
|
||||
path: out/mousesoft.json
|
||||
overwrite: true
|
||||
|
||||
- name: set-up dependencies
|
||||
run: |
|
||||
go install github.com/kisielk/errcheck@latest
|
||||
go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||
go install github.com/sashamelentyev/usestdlibvars@latest
|
||||
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
|
||||
make vendor
|
||||
|
||||
- name: lint
|
||||
run: make lint
|
||||
|
||||
- name: golangci-lint
|
||||
uses: https://github.com/golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: v1.60
|
||||
|
||||
- name: build amd64
|
||||
id: build-amd64
|
||||
run: |
|
||||
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-amd64" >> $GITHUB_OUTPUT
|
||||
GOARCH=amd64 make clean build package
|
||||
|
||||
- name: upload amd64
|
||||
uses: https://gitea.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ steps.build-amd64.outputs.ARTIFACT }}
|
||||
path: |
|
||||
out/*.changes
|
||||
out/*.deb
|
||||
overwrite: true
|
||||
|
||||
- name: build arm64
|
||||
id: build-arm64
|
||||
run: |
|
||||
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-arm64" >> $GITHUB_OUTPUT
|
||||
GOARCH=arm64 make clean build package
|
||||
|
||||
- name: upload arm64
|
||||
uses: https://gitea.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ steps.build-arm64.outputs.ARTIFACT }}
|
||||
path: |
|
||||
out/*.changes
|
||||
out/*.deb
|
||||
overwrite: true
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build
|
||||
steps:
|
||||
- name: download dput profile
|
||||
uses: https://gitea.com/actions/download-artifact@v3-node20
|
||||
with:
|
||||
name: mousesoft_dput_profile
|
||||
path: /etc/dput.d/profiles/
|
||||
|
||||
- name: download linux amd64 package
|
||||
uses: https://gitea.com/actions/download-artifact@v3-node20
|
||||
with:
|
||||
name: ${{ needs.build_linux.outputs.artifact_amd64 }}
|
||||
|
||||
- name: download linux arm64 package
|
||||
uses: https://gitea.com/actions/download-artifact@v3-node20
|
||||
with:
|
||||
name: ${{ needs.build_linux.outputs.artifact_arm64 }}
|
||||
|
||||
- name: deploy packages
|
||||
env:
|
||||
SSH_HOST: ${{ secrets.DEB_SSH_HOST }}
|
||||
SSH_PORT: ${{ secrets.DEB_SSH_PORT }}
|
||||
SSH_USER: ${{ secrets.DEB_SSH_USER }}
|
||||
SSH_KEY: ${{ secrets.DEB_SSH_KEY }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh/
|
||||
echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/key
|
||||
chmod 0600 ~/.ssh/key
|
||||
cat >>~/.ssh/config <<END
|
||||
Host $SSH_HOST
|
||||
IdentitiesOnly yes
|
||||
User $SSH_USER
|
||||
IdentityFile ~/.ssh/key
|
||||
Port $SSH_PORT
|
||||
StrictHostKeyChecking no
|
||||
END
|
||||
make deploy-deb
|
||||
|
||||
- name: release
|
||||
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||
with:
|
||||
title: "MouseSoft DrawIO-Export ${{ needs.build.outputs.version }}"
|
||||
body: "${{ needs.build.outputs.changes }}"
|
||||
files: |
|
||||
*.deb
|
||||
sha256sum: true
|
||||
prerelease: true
|
||||
draft: true
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,6 +12,8 @@
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
out
|
||||
tmp
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
|
5
build/package/debian/changelog.tpl
Normal file
5
build/package/debian/changelog.tpl
Normal file
@ -0,0 +1,5 @@
|
||||
transocks (VERSION) mousesoft-stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
-- Aleksei Badiaev <aleksei.badiaev@mousesoft.ru> Sun, 9 Apr 2023 21:45:22 +0700
|
8
build/package/debian/control.tpl
Normal file
8
build/package/debian/control.tpl
Normal file
@ -0,0 +1,8 @@
|
||||
Source: transocks
|
||||
Maintainer: Aleksei Badiaev <aleksei.badiaev@mousesoft.ru>
|
||||
|
||||
Package: transocks
|
||||
Section: network
|
||||
Priority: optional
|
||||
Architecture: ARCH
|
||||
Description: transocks - a transparent SOCKS5/HTTP proxy
|
12
deploy/dput/mousesoft.json.tpl
Normal file
12
deploy/dput/mousesoft.json.tpl
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"allow_unsigned_uploads": true,
|
||||
"full_upload_log": false,
|
||||
"fqdn": "DEB_SSH_HOST",
|
||||
"hash": "sha1",
|
||||
"interface": "cli",
|
||||
"incoming": "mini-dinstall/incoming/",
|
||||
"login": "mini-dinstall",
|
||||
"meta": "boring",
|
||||
"method": "scp",
|
||||
"scp_compress": true
|
||||
}
|
69
makefile
69
makefile
@ -14,8 +14,8 @@ BINDIR ?= $(OUTDIR)/bin
|
||||
VERSION ?= $(strip $(shell ./scripts/version.sh))
|
||||
VERSION_NUMBER := $(strip $(shell ./scripts/version.sh number))
|
||||
|
||||
BUILD_OS ?= $(shell go env GOOS)
|
||||
BUILD_ARCH ?= $(shell go env GOARCH)
|
||||
GOOS ?= $(shell go env GOOS)
|
||||
GOARCH ?= $(shell go env GOARCH)
|
||||
|
||||
GO_LDFLAGS ?=
|
||||
GO_OPT_V := -X "main.version=$(VERSION)"
|
||||
@ -29,19 +29,9 @@ GOTEST := $(GOCMD) test
|
||||
GOVET := $(GOCMD) vet
|
||||
ECHO_CMD := echo -e
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
MSI_FILE ?= $(PROJECT_ID)_$(VERSION)_$(BUILD_ARCH).msi
|
||||
DIST_EXT := .zip
|
||||
DIST_OPTS := -a -cf
|
||||
MSI_VERSION := $(shell echo $(VERSION_NUMBER) | sed -e 's/-.*//')
|
||||
BIN_SUFFIX := .exe
|
||||
else
|
||||
PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||
DIST_EXT := .tar.gz
|
||||
DIST_OPTS := -czf
|
||||
endif
|
||||
|
||||
PKG_NAME := $(PROJECT_ID)_$(VERSION)_$(BUILD_OS)-$(BUILD_ARCH)
|
||||
PKG_NAME := $(PROJECT_ID)_$(VERSION)_$(GOOS)-$(GOARCH)
|
||||
DIST_FILE := $(PKG_NAME)$(DIST_EXT)
|
||||
|
||||
GREEN := $(shell tput -Txterm setaf 2)
|
||||
@ -65,6 +55,17 @@ version-number: ## Version number of the project to be built
|
||||
all: clean vendor build ## Build binary
|
||||
.PHONY:all
|
||||
|
||||
clean: ## Remove build related files
|
||||
@rm -fr $(TMPDIR)
|
||||
@rm -fr $(OUTDIR)
|
||||
@$(ECHO_CMD) "Clean\t\t${GREEN}[OK]${RESET}"
|
||||
.PHONY:clean
|
||||
|
||||
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
|
||||
$(GOCMD) mod vendor
|
||||
@$(ECHO_CMD) "Vendor\t\t${GREEN}[OK]${RESET}"
|
||||
.PHONY:vendor
|
||||
|
||||
APPS := $(patsubst cmd/%/, %, $(dir $(wildcard cmd/*/main.go)))
|
||||
|
||||
build: $(addprefix $(BINDIR)/, $(APPS)) ## Build your project and put the output binary in out/bin/
|
||||
@ -78,22 +79,44 @@ $(BINDIR)/%: cmd/%/main.go $(patsubst cmd/%/main.go,cmd/%/*.go,$<)
|
||||
-o "$(BINDIR)/$(BIN_PREFIX)$(patsubst cmd/%/main.go,%,$<)$(BIN_SUFFIX)" \
|
||||
$(patsubst %/main.go,./%,$<)
|
||||
|
||||
dist: ## Create all distro packages
|
||||
dist: ## Create binary distro package
|
||||
@rm -f "$(OUTDIR)/$(DIST_FILE)"
|
||||
tar $(DIST_OPTS) "$(OUTDIR)/$(DIST_FILE)" -C "$(OUTDIR)" bin
|
||||
@$(ECHO_CMD) "Dist\t\t${GREEN}[OK]${RESET}"
|
||||
.PHONY:dist
|
||||
|
||||
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
|
||||
$(GOCMD) mod vendor
|
||||
@$(ECHO_CMD) "Vendor\t\t${GREEN}[OK]${RESET}"
|
||||
.PHONY:vendor
|
||||
DEB_NAME := $(PROJECT_ID)_$(VERSION_NUMBER)-1_$(GOARCH)
|
||||
|
||||
clean: ## Remove build related files
|
||||
@rm -fr $(TMPDIR)
|
||||
@rm -fr $(OUTDIR)
|
||||
@$(ECHO_CMD) "Clean\t\t${GREEN}[OK]${RESET}"
|
||||
.PHONY:clean
|
||||
pkg-deb: ## Build debian package
|
||||
@rm -rf $(TMPDIR)
|
||||
@mkdir -p $(TMPDIR)/$(DEB_NAME)/usr/bin
|
||||
@mkdir -p $(TMPDIR)/$(DEB_NAME)/debian
|
||||
@mkdir -p $(TMPDIR)/$(DEB_NAME)/DEBIAN
|
||||
@cp -a $(BINDIR)/* $(TMPDIR)/$(DEB_NAME)/usr/bin/
|
||||
@sed -e "s/VERSION/$(VERSION_NUMBER)/g" \
|
||||
$(CURDIR)/build/package/debian/changelog.tpl \
|
||||
> $(TMPDIR)/$(DEB_NAME)/changelog
|
||||
@sed -e "s/ARCH/$(GOARCH)/g" $(CURDIR)/build/package/debian/control.tpl \
|
||||
> $(TMPDIR)/$(DEB_NAME)/control
|
||||
DEB_HOST_ARCH=$(GOARCH) dpkg-gencontrol -v$(VERSION_NUMBER)-1 \
|
||||
-c$(TMPDIR)/$(DEB_NAME)/control \
|
||||
-l$(TMPDIR)/$(DEB_NAME)/changelog \
|
||||
-f$(TMPDIR)/$(DEB_NAME)/debian/files -Ptmp/$(DEB_NAME)
|
||||
dpkg-deb --build --root-owner-group $(TMPDIR)/$(DEB_NAME)
|
||||
dpkg-genchanges --build=binary \
|
||||
-c$(TMPDIR)/$(DEB_NAME)/control \
|
||||
-l$(TMPDIR)/$(DEB_NAME)/changelog \
|
||||
-f$(TMPDIR)/$(DEB_NAME)/debian/files \
|
||||
-u$(TMPDIR) -O$(OUTDIR)/$(DEB_NAME).changes
|
||||
@mv $(TMPDIR)/*.deb $(OUTDIR)/
|
||||
@$(ECHO_CMD) "pkg-deb\t\t${GREEN}[OK]${RESET}"
|
||||
.PHONY:pkg-deb
|
||||
|
||||
## Deploy
|
||||
|
||||
deploy-deb: ## Deploy debian packages
|
||||
find -O1 $(OUT_DIR) -name '*.changes' -exec dput mousesoft \{\} \;
|
||||
.PHONY:deploy
|
||||
|
||||
## Test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user