Настроена сборка deb пакета.
All checks were successful
build / linux (push) Successful in 1m15s

This commit is contained in:
Алексей Бадяев 2024-11-01 23:26:06 +07:00
parent a59ad95f63
commit 8dd4b1a7d9
Signed by: alexey
GPG Key ID: 686FBC1363E4AFAE
7 changed files with 200 additions and 102 deletions

View File

@ -10,7 +10,7 @@ on:
- "v*" - "v*"
jobs: jobs:
build: linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: check-out - name: check-out
@ -41,7 +41,7 @@ jobs:
version: v1.60 version: v1.60
- name: build amd64 - name: build amd64
id: build-amd id: build-amd64
run: | run: |
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-amd64" >> $GITHUB_OUTPUT echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-amd64" >> $GITHUB_OUTPUT
GOARCH=amd64 make clean build GOARCH=amd64 make clean build
@ -49,12 +49,12 @@ jobs:
- name: upload amd64 - name: upload amd64
uses: https://gitea.com/actions/upload-artifact@v3 uses: https://gitea.com/actions/upload-artifact@v3
with: with:
name: ${{ steps.build-amd.outputs.ARTIFACT }} name: ${{ steps.build-amd64.outputs.ARTIFACT }}
path: out/bin/* path: out/bin/*
overwrite: true overwrite: true
- name: build arm64 - name: build arm64
id: build-arm id: build-arm64
run: | run: |
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-arm64" >> $GITHUB_OUTPUT echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-arm64" >> $GITHUB_OUTPUT
GOARCH=arm64 make clean build GOARCH=arm64 make clean build
@ -62,47 +62,6 @@ jobs:
- name: upload arm64 - name: upload arm64
uses: https://gitea.com/actions/upload-artifact@v3 uses: https://gitea.com/actions/upload-artifact@v3
with: with:
name: ${{ steps.build-arm.outputs.ARTIFACT }} name: ${{ steps.build-arm64.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 }}
path: out/bin/* path: out/bin/*
overwrite: true overwrite: true

View File

@ -1,13 +1,20 @@
name: release name: release
run-name: ${{ gitea.actor }} release Transocks
on: on:
push: push:
tags: tags:
- "v*" - "v*"
jobs: jobs:
release: build:
runs-on: ubuntu-latest 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: steps:
- name: check-out - name: check-out
uses: https://gitea.com/actions/checkout@v4 uses: https://gitea.com/actions/checkout@v4
@ -15,42 +22,124 @@ jobs:
fetch-depth: 0 fetch-depth: 0
fetch-tags: true fetch-tags: true
- name: set-up qemu - name: set-up go
uses: https://git.mousesoft.ru/ms/gitea-action-setup-qemu@v3 uses: https://gitea.com/actions/setup-go@v3
- name: set-up docker buildx
uses: https://git.mousesoft.ru/ms/gitea-action-docker-setup-buildx@v3
with: with:
buildkitd-flags: --debug go-version: ">=1.22"
- 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 }}
- name: meta - name: meta
id: meta id: meta
env:
SSH_HOST: ${{ secrets.DEB_SSH_HOST }}
run: | run: |
echo IMAGE_CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | tee -a $GITHUB_OUTPUT echo "VERSION=$(make version)" >> $GITHUB_OUTPUT
echo IMAGE_VERSION=$(./version.sh n) | tee -a $GITHUB_OUTPUT echo 'CHANGES<<EOF' >> $GITHUB_OUTPUT
echo IMAGE_REVISION=$(git rev-parse HEAD) | tee -a $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 - name: upload dput profile
uses: https://git.mousesoft.ru/ms/gitea-action-docker-build-push@v6 uses: https://gitea.com/actions/upload-artifact@v3
with: with:
context: . name: mousesoft_dput_profile
file: Dockerfile path: out/mousesoft.json
platforms: | overwrite: true
linux/amd64
linux/arm64 - name: set-up dependencies
pull: true run: |
push: true go install github.com/kisielk/errcheck@latest
no-cache: true go install honnef.co/go/tools/cmd/staticcheck@latest
build-args: | go install github.com/sashamelentyev/usestdlibvars@latest
IMAGE_VERSION=${{ steps.meta.outputs.IMAGE_VERSION }} go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
IMAGE_CREATED=${{ steps.meta.outputs.IMAGE_CREATED }} make vendor
tags: |
git.mousesoft.ru/alexey/transocks:${{ steps.meta.outputs.IMAGE_VERSION }} - name: lint
git.mousesoft.ru/alexey/transocks:latest 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
View File

@ -12,6 +12,8 @@
# Folders # Folders
_obj _obj
_test _test
out
tmp
# Architecture specific extensions/prefixes # Architecture specific extensions/prefixes
*.[568vq] *.[568vq]

View 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

View 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

View 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
}

View File

@ -14,8 +14,8 @@ BINDIR ?= $(OUTDIR)/bin
VERSION ?= $(strip $(shell ./scripts/version.sh)) VERSION ?= $(strip $(shell ./scripts/version.sh))
VERSION_NUMBER := $(strip $(shell ./scripts/version.sh number)) VERSION_NUMBER := $(strip $(shell ./scripts/version.sh number))
BUILD_OS ?= $(shell go env GOOS) GOOS ?= $(shell go env GOOS)
BUILD_ARCH ?= $(shell go env GOARCH) GOARCH ?= $(shell go env GOARCH)
GO_LDFLAGS ?= GO_LDFLAGS ?=
GO_OPT_V := -X "main.version=$(VERSION)" GO_OPT_V := -X "main.version=$(VERSION)"
@ -29,19 +29,9 @@ GOTEST := $(GOCMD) test
GOVET := $(GOCMD) vet GOVET := $(GOCMD) vet
ECHO_CMD := echo -e 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_EXT := .tar.gz
DIST_OPTS := -czf DIST_OPTS := -czf
endif PKG_NAME := $(PROJECT_ID)_$(VERSION)_$(GOOS)-$(GOARCH)
PKG_NAME := $(PROJECT_ID)_$(VERSION)_$(BUILD_OS)-$(BUILD_ARCH)
DIST_FILE := $(PKG_NAME)$(DIST_EXT) DIST_FILE := $(PKG_NAME)$(DIST_EXT)
GREEN := $(shell tput -Txterm setaf 2) 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 all: clean vendor build ## Build binary
.PHONY:all .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))) APPS := $(patsubst cmd/%/, %, $(dir $(wildcard cmd/*/main.go)))
build: $(addprefix $(BINDIR)/, $(APPS)) ## Build your project and put the output binary in out/bin/ 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)" \ -o "$(BINDIR)/$(BIN_PREFIX)$(patsubst cmd/%/main.go,%,$<)$(BIN_SUFFIX)" \
$(patsubst %/main.go,./%,$<) $(patsubst %/main.go,./%,$<)
dist: ## Create all distro packages dist: ## Create binary distro package
@rm -f "$(OUTDIR)/$(DIST_FILE)" @rm -f "$(OUTDIR)/$(DIST_FILE)"
tar $(DIST_OPTS) "$(OUTDIR)/$(DIST_FILE)" -C "$(OUTDIR)" bin tar $(DIST_OPTS) "$(OUTDIR)/$(DIST_FILE)" -C "$(OUTDIR)" bin
@$(ECHO_CMD) "Dist\t\t${GREEN}[OK]${RESET}" @$(ECHO_CMD) "Dist\t\t${GREEN}[OK]${RESET}"
.PHONY:dist .PHONY:dist
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory DEB_NAME := $(PROJECT_ID)_$(VERSION_NUMBER)-1_$(GOARCH)
$(GOCMD) mod vendor
@$(ECHO_CMD) "Vendor\t\t${GREEN}[OK]${RESET}"
.PHONY:vendor
clean: ## Remove build related files pkg-deb: ## Build debian package
@rm -fr $(TMPDIR) @rm -rf $(TMPDIR)
@rm -fr $(OUTDIR) @mkdir -p $(TMPDIR)/$(DEB_NAME)/usr/bin
@$(ECHO_CMD) "Clean\t\t${GREEN}[OK]${RESET}" @mkdir -p $(TMPDIR)/$(DEB_NAME)/debian
.PHONY:clean @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 ## Test