From e8db2297989f0f1ed0a0e822f85d408decc32b6a Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 15:32:42 +0800 Subject: [PATCH 01/33] feat: Cross-platform build support for Makefile and GitHub Actions - Added cross-platform detection for Windows and Unix-like systems in Makefile - Updated build configuration to dynamically set platform-specific variables - Modified config initialization to support Windows and Unix environments - Enhanced PyInstaller build command with platform and architecture detection - Simplified rsync upload process in GitHub Actions workflow - Expanded hidden imports for improved binary compatibility --- .github/workflows/package.yml | 6 ++-- Makefile | 57 +++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index a37b807..4674681 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -159,9 +159,7 @@ jobs: - name: Upload to server via rsync env: - RSYNC_PASSWORD: ${{ secrets.RSYNC_PASSWORD }} - RSYNC_HOST: ${{ secrets.RSYNC_HOST }} VERSION: ${{ steps.get_version.outputs.VERSION }} run: | - echo "${{ env.RSYNC_PASSWORD }}" > /tmp/rsync_password && chmod 600 /tmp/rsync_password - rsync --password-file=/tmp/rsync_password -avz --progress upload/ "rsync://${RSYNC_HOST}/data/enterprise-artifact/gz/tapflow/${VERSION}/" \ No newline at end of file + echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync_password && chmod 600 /tmp/rsync_password + rsync --password-file=/tmp/rsync_password -avz --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" \ No newline at end of file diff --git a/Makefile b/Makefile index 19b4c8d..c5041fc 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,24 @@ DIST_DIR = dist BUILD_DIR = build CONFIG_DIR = $(HOME)/.tapflow +# 检测操作系统 +ifeq ($(OS),Windows_NT) + PLATFORM = windows + ARCH = $(shell echo %PROCESSOR_ARCHITECTURE%) + PYTHON = $(VENV)\Scripts\python + PIP = $(VENV)\Scripts\pip + CONFIG_DIR = $(USERPROFILE)\.tapflow + SEP = \\ +else + PLATFORM = $(shell uname -s | tr '[:upper:]' '[:lower:]') + ARCH = $(shell uname -m) + PYTHON = $(VENV)/bin/python + PIP = $(VENV)/bin/pip + SEP = / +endif + # Python 虚拟环境 VENV = .venv -PYTHON = $(VENV)/bin/python -PIP = $(VENV)/bin/pip # 默认目标 .PHONY: all @@ -32,19 +46,28 @@ clean: # 初始化配置文件 .PHONY: init-config init-config: +ifeq ($(OS),Windows_NT) + if not exist "$(CONFIG_DIR)" mkdir "$(CONFIG_DIR)" + if not exist "$(CONFIG_DIR)\config.ini" ( + echo [backend] > "$(CONFIG_DIR)\config.ini" + echo server = localhost >> "$(CONFIG_DIR)\config.ini" + echo access_code = >> "$(CONFIG_DIR)\config.ini" + ) +else mkdir -p $(CONFIG_DIR) @if [ ! -f "$(CONFIG_DIR)/config.ini" ]; then \ echo "[backend]" > $(CONFIG_DIR)/config.ini; \ echo "server = localhost" >> $(CONFIG_DIR)/config.ini; \ echo "access_code = " >> $(CONFIG_DIR)/config.ini; \ fi +endif # 构建当前平台版本 .PHONY: current current: init-config PYTHONPATH=$(PWD) $(PYTHON) -m PyInstaller \ --clean \ - --name $(PACKAGE_NAME)-$(VERSION)-$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(shell uname -m) \ + --name $(PACKAGE_NAME)-$(VERSION)-$(PLATFORM)-$(ARCH) \ --add-data "requirements.txt:." \ --add-data "README.md:." \ --add-data "tapflow/cli/cli.py:tapflow/cli" \ @@ -60,11 +83,39 @@ current: init-config --hidden-import tapflow.lib.backend_apis \ --hidden-import tapflow.lib.data_pipeline \ --hidden-import tapflow.lib.connections \ + --hidden-import tapflow.lib.utils \ + --hidden-import tapflow.lib.params \ + --hidden-import tapflow.lib.data_pipeline.validation \ + --hidden-import tapflow.lib.data_services \ + --hidden-import tapflow.lib.system \ + --hidden-import tapflow.lib.cache \ + --hidden-import tapflow.lib.backend_apis.common \ + --hidden-import tapflow.lib.backend_apis.connections \ + --hidden-import tapflow.lib.backend_apis.task \ + --hidden-import tapflow.lib.backend_apis.dataVerify \ + --hidden-import tapflow.lib.backend_apis.metadataInstance \ + --hidden-import tapflow.lib.backend_apis.apiServers \ --hidden-import IPython \ --hidden-import yaml \ --hidden-import requests \ --hidden-import websockets \ --hidden-import bson \ + --hidden-import urllib \ + --hidden-import traitlets \ + --hidden-import importlib.metadata \ + --hidden-import logging \ + --hidden-import email \ + --hidden-import xml \ + --hidden-import http \ + --hidden-import ctypes \ + --hidden-import multiprocessing \ + --hidden-import dateutil \ + --hidden-import json \ + --hidden-import asyncio \ + --hidden-import concurrent.futures \ + --hidden-import idna \ + --hidden-import urllib3 \ + --hidden-import charset_normalizer \ --log-level ERROR \ --onefile \ $(MAIN_ENTRY) \ No newline at end of file From 052bc1de13993dfbd83d7574b07567ce81e9943e Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 15:42:57 +0800 Subject: [PATCH 02/33] fix: optimize rsync upload command in package workflow - Updated rsync command flags for more efficient file transfer - Replaced `-avz` with `-vzrt` to improve transfer performance - Maintained existing secure password handling and upload destination --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 4674681..cc640c9 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -162,4 +162,4 @@ jobs: VERSION: ${{ steps.get_version.outputs.VERSION }} run: | echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync_password && chmod 600 /tmp/rsync_password - rsync --password-file=/tmp/rsync_password -avz --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" \ No newline at end of file + rsync --password-file=/tmp/rsync_password -vzrt --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" \ No newline at end of file From eca42f4af330d9d9567d2284ae56e291f3fb200f Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 15:57:35 +0800 Subject: [PATCH 03/33] fix: enhance rsync upload with temporary directory and permissions - Added temporary directory for rsync transfer to improve reliability - Set explicit file and directory permissions for uploaded artifacts - Maintained existing secure password handling and upload destination --- .github/workflows/package.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index cc640c9..2ba58c9 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -162,4 +162,5 @@ jobs: VERSION: ${{ steps.get_version.outputs.VERSION }} run: | echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync_password && chmod 600 /tmp/rsync_password - rsync --password-file=/tmp/rsync_password -vzrt --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" \ No newline at end of file + mkdir -p /tmp/rsync_temp + rsync --password-file=/tmp/rsync_password -vzrt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --temp-dir=/tmp/rsync_temp --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" \ No newline at end of file From e6d4135400137751ba3a5a9d39fbf819ffe31a50 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:00:47 +0800 Subject: [PATCH 04/33] fix: handle rsync upload errors with graceful exit strategy - Added error handling to rsync command to allow exit code 23 (partial transfer) - Maintained existing secure password handling and upload configuration - Improved workflow reliability by preventing unnecessary workflow failures --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2ba58c9..c4ba562 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -163,4 +163,4 @@ jobs: run: | echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync_password && chmod 600 /tmp/rsync_password mkdir -p /tmp/rsync_temp - rsync --password-file=/tmp/rsync_password -vzrt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --temp-dir=/tmp/rsync_temp --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" \ No newline at end of file + rsync --password-file=/tmp/rsync_password -vzrt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --temp-dir=/tmp/rsync_temp --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || [[ $? -eq 23 ]] || exit $? \ No newline at end of file From 2cacbdd2305c7a7ac0330351b8e47b5f51e5da4f Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:03:22 +0800 Subject: [PATCH 05/33] fix: modify rsync upload error handling to always exit successfully - Updated rsync command to use `|| true` for unconditional success - Ensures workflow continues even if rsync encounters partial transfer or other non-critical errors - Maintains existing secure password handling and upload configuration --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index c4ba562..bbffe6c 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -163,4 +163,4 @@ jobs: run: | echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync_password && chmod 600 /tmp/rsync_password mkdir -p /tmp/rsync_temp - rsync --password-file=/tmp/rsync_password -vzrt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --temp-dir=/tmp/rsync_temp --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || [[ $? -eq 23 ]] || exit $? \ No newline at end of file + rsync --password-file=/tmp/rsync_password -vzrt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --temp-dir=/tmp/rsync_temp --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || true \ No newline at end of file From aa5319675684e879291625bec2dd7c94328a86d0 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:06:33 +0800 Subject: [PATCH 06/33] refactor: simplify rsync upload command in package workflow - Removed temporary directory creation step - Simplified rsync command by removing unnecessary flags - Maintained secure password handling and upload destination --- .github/workflows/package.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index bbffe6c..cc640c9 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -162,5 +162,4 @@ jobs: VERSION: ${{ steps.get_version.outputs.VERSION }} run: | echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync_password && chmod 600 /tmp/rsync_password - mkdir -p /tmp/rsync_temp - rsync --password-file=/tmp/rsync_password -vzrt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --temp-dir=/tmp/rsync_temp --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || true \ No newline at end of file + rsync --password-file=/tmp/rsync_password -vzrt --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" \ No newline at end of file From 1258b585afbcd3863f2257c391404f43965dba79 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:21:00 +0800 Subject: [PATCH 07/33] refactor: Enhance cross-platform build and deployment configuration - Updated Makefile to support dynamic platform detection and configuration - Simplified build commands for Windows and Unix-like systems - Improved GitHub Actions workflow to use Makefile for consistent builds - Added Windows platform support in build matrix - Streamlined artifact generation and checksum creation - Replaced custom rsync upload with GitHub Actions rsync deployment --- .github/workflows/package.yml | 139 ++++++---------------------------- Makefile | 50 ++++++------ 2 files changed, 49 insertions(+), 140 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index cc640c9..b7c8e0c 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -8,18 +8,19 @@ on: jobs: # 二进制文件构建任务 - build-binaries: + build-and-publish: strategy: matrix: include: - os: ubuntu-latest platform: linux arch: x86_64 - ext: "" - os: macos-latest platform: darwin arch: x86_64 - ext: "" + - os: windows-latest + platform: windows + arch: x86_64 runs-on: ${{ matrix.os }} @@ -43,123 +44,27 @@ jobs: echo "VERSION=latest" >> $GITHUB_ENV fi - - name: Install dependencies + - name: Install make (Windows) + if: runner.os == 'Windows' run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pyinstaller - - - name: Create config directory (Unix) - run: mkdir -p ~/.tapflow - + choco install make + - name: Build binary run: | - python -m PyInstaller \ - --clean \ - --name tapflow-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }} \ - --add-data "requirements.txt:." \ - --add-data "README.md:." \ - --add-data "tapflow/cli/cli.py:tapflow/cli" \ - --add-data "etc:etc" \ - --add-data "tapflow:tapflow" \ - --hidden-import tapflow \ - --hidden-import tapflow.cli \ - --hidden-import tapflow.cli.cli \ - --hidden-import tapflow.cli.tap \ - --hidden-import tapflow.lib \ - --hidden-import tapflow.lib.configuration \ - --hidden-import tapflow.lib.configuration.config \ - --hidden-import tapflow.lib.backend_apis \ - --hidden-import tapflow.lib.data_pipeline \ - --hidden-import tapflow.lib.connections \ - --hidden-import tapflow.lib.utils \ - --hidden-import tapflow.lib.params \ - --hidden-import tapflow.lib.data_pipeline.validation \ - --hidden-import tapflow.lib.data_services \ - --hidden-import tapflow.lib.system \ - --hidden-import tapflow.lib.cache \ - --hidden-import tapflow.lib.backend_apis.common \ - --hidden-import tapflow.lib.backend_apis.connections \ - --hidden-import tapflow.lib.backend_apis.task \ - --hidden-import tapflow.lib.backend_apis.dataVerify \ - --hidden-import tapflow.lib.backend_apis.metadataInstance \ - --hidden-import tapflow.lib.backend_apis.apiServers \ - --hidden-import IPython \ - --hidden-import yaml \ - --hidden-import requests \ - --hidden-import websockets \ - --hidden-import bson \ - --hidden-import urllib \ - --hidden-import traitlets \ - --hidden-import importlib.metadata \ - --hidden-import logging \ - --hidden-import email \ - --hidden-import xml \ - --hidden-import http \ - --hidden-import ctypes \ - --hidden-import multiprocessing \ - --hidden-import dateutil \ - --hidden-import json \ - --hidden-import asyncio \ - --hidden-import concurrent.futures \ - --hidden-import idna \ - --hidden-import urllib3 \ - --hidden-import charset_normalizer \ - --log-level ERROR \ - --onefile \ - tapflow/cli/tap.py + make clean setup current - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: binary-${{ matrix.platform }}-${{ matrix.arch }} - path: dist/*${{ matrix.ext }} - retention-days: 1 - - # 发布二进制文件到服务器任务 - publish-binaries: - needs: [build-binaries] - runs-on: ubuntu-latest - - steps: - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: dist - merge-multiple: true - - - name: Install rsync - run: sudo apt-get install -y rsync - - - name: Get version from tag - id: get_version - run: | - if [[ $GITHUB_REF == refs/tags/* ]]; then - echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT - else - echo "VERSION=latest" >> $GITHUB_OUTPUT - fi - - - name: Prepare artifacts for upload + - name: Generate checksum + shell: bash run: | - mkdir -p upload - # 显示当前目录结构以便调试 - echo "Current directory structure:" - ls -R dist/ - # 直接复制 dist 目录下的所有文件 - cp -r dist/*/* upload/ || cp -r dist/* upload/ - cd upload - # 确保目录不为空再生成校验和 - if [ "$(ls -A)" ]; then - sha256sum * > SHA256SUMS.txt - else - echo "Error: No files found to generate checksums" - exit 1 - fi + cd dist + sha256sum * > SHA256SUMS.txt - - name: Upload to server via rsync - env: - VERSION: ${{ steps.get_version.outputs.VERSION }} - run: | - echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync_password && chmod 600 /tmp/rsync_password - rsync --password-file=/tmp/rsync_password -vzrt --progress upload/ "rsync://${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" \ No newline at end of file + - name: Deploy to rsync server + uses: Burnett01/rsync-deployments@6.0.0 + with: + switches: -tvzr --delete + path: dist/ + remote_path: /data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/ + remote_host: ${{ secrets.RSYNC_HOST }} + remote_user: ${{ secrets.RSYNC_USER }} + remote_key: ${{ secrets.RSYNC_PASSWORD }} \ No newline at end of file diff --git a/Makefile b/Makefile index c5041fc..199c7e5 100644 --- a/Makefile +++ b/Makefile @@ -4,22 +4,32 @@ VERSION = 0.2.54 MAIN_ENTRY = tapflow/cli/tap.py DIST_DIR = dist BUILD_DIR = build -CONFIG_DIR = $(HOME)/.tapflow # 检测操作系统 ifeq ($(OS),Windows_NT) PLATFORM = windows - ARCH = $(shell echo %PROCESSOR_ARCHITECTURE%) - PYTHON = $(VENV)\Scripts\python - PIP = $(VENV)\Scripts\pip - CONFIG_DIR = $(USERPROFILE)\.tapflow - SEP = \\ + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + ARCH = x86_64 + else ifeq ($(PROCESSOR_ARCHITECTURE),x86) + ARCH = x86 + else + ARCH = $(PROCESSOR_ARCHITECTURE) + endif + PYTHON = python + PIP = pip + CONFIG_DIR = $(subst \,/,$(USERPROFILE))/.tapflow + MKDIR = powershell -Command "New-Item -ItemType Directory -Force -Path" + RMRF = powershell -Command "Remove-Item -Recurse -Force" + COPY = powershell -Command "Copy-Item" else PLATFORM = $(shell uname -s | tr '[:upper:]' '[:lower:]') ARCH = $(shell uname -m) - PYTHON = $(VENV)/bin/python - PIP = $(VENV)/bin/pip - SEP = / + PYTHON = python3 + PIP = pip3 + CONFIG_DIR = $(HOME)/.tapflow + MKDIR = mkdir -p + RMRF = rm -rf + COPY = cp endif # Python 虚拟环境 @@ -32,7 +42,7 @@ all: clean setup current # 设置虚拟环境 .PHONY: setup setup: - python3 -m venv $(VENV) + $(PYTHON) -m venv $(VENV) $(PIP) install --upgrade pip $(PIP) install -r requirements.txt $(PIP) install pyinstaller @@ -40,32 +50,26 @@ setup: # 清理构建文件 .PHONY: clean clean: - rm -rf $(DIST_DIR) $(BUILD_DIR) - rm -rf *.spec + $(RMRF) "$(DIST_DIR)" "$(BUILD_DIR)" *.spec # 初始化配置文件 .PHONY: init-config init-config: + $(MKDIR) "$(CONFIG_DIR)" ifeq ($(OS),Windows_NT) - if not exist "$(CONFIG_DIR)" mkdir "$(CONFIG_DIR)" - if not exist "$(CONFIG_DIR)\config.ini" ( - echo [backend] > "$(CONFIG_DIR)\config.ini" - echo server = localhost >> "$(CONFIG_DIR)\config.ini" - echo access_code = >> "$(CONFIG_DIR)\config.ini" - ) + powershell -Command "if (-not (Test-Path '$(CONFIG_DIR)/config.ini')) { @('[backend]', 'server = localhost', 'access_code = ') | Set-Content '$(CONFIG_DIR)/config.ini' -Encoding UTF8 }" else - mkdir -p $(CONFIG_DIR) @if [ ! -f "$(CONFIG_DIR)/config.ini" ]; then \ - echo "[backend]" > $(CONFIG_DIR)/config.ini; \ - echo "server = localhost" >> $(CONFIG_DIR)/config.ini; \ - echo "access_code = " >> $(CONFIG_DIR)/config.ini; \ + echo "[backend]" > "$(CONFIG_DIR)/config.ini"; \ + echo "server = localhost" >> "$(CONFIG_DIR)/config.ini"; \ + echo "access_code = " >> "$(CONFIG_DIR)/config.ini"; \ fi endif # 构建当前平台版本 .PHONY: current current: init-config - PYTHONPATH=$(PWD) $(PYTHON) -m PyInstaller \ + $(PYTHON) -m PyInstaller \ --clean \ --name $(PACKAGE_NAME)-$(VERSION)-$(PLATFORM)-$(ARCH) \ --add-data "requirements.txt:." \ From 6d5d80505315e971f0b02c1cd9b53b37b010c3e0 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:23:27 +0800 Subject: [PATCH 08/33] feat: Improve Windows checksum generation in package workflow - Added platform-specific checksum generation for Windows - Implemented PowerShell script to generate SHA256 checksums - Fixed line endings for Windows-generated checksum file - Ensured consistent checksum file format across platforms --- .github/workflows/package.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index b7c8e0c..a70c99c 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -50,15 +50,36 @@ jobs: choco install make - name: Build binary + shell: bash + env: + PYTHONPATH: ${{ github.workspace }} run: | make clean setup current - - name: Generate checksum + - name: Generate checksum (Unix) + if: runner.os != 'Windows' shell: bash run: | cd dist sha256sum * > SHA256SUMS.txt + - name: Generate checksum (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + cd dist + Get-ChildItem -File | ForEach-Object { + $hash = (Get-FileHash -Algorithm SHA256 $_.Name).Hash.ToLower() + "$hash $($_.Name)" | Out-File -Append -Encoding utf8 SHA256SUMS.txt + } + + - name: Fix line endings (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + cd dist + (Get-Content SHA256SUMS.txt) | Set-Content -Encoding utf8 SHA256SUMS.txt + - name: Deploy to rsync server uses: Burnett01/rsync-deployments@6.0.0 with: From 5cbc5801737c142ab9806f435daa01ff044f9b64 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:26:13 +0800 Subject: [PATCH 09/33] fix: Improve Windows-specific clean command in Makefile - Updated clean target to use platform-specific file removal command - Added conditional handling for Windows file and directory deletion - Ensured consistent clean behavior across Windows and Unix-like systems --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 199c7e5..1d1e300 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ ifeq ($(OS),Windows_NT) PIP = pip CONFIG_DIR = $(subst \,/,$(USERPROFILE))/.tapflow MKDIR = powershell -Command "New-Item -ItemType Directory -Force -Path" - RMRF = powershell -Command "Remove-Item -Recurse -Force" + RMRF = powershell -Command "if (Test-Path '$(1)') { Remove-Item -Recurse -Force '$(1)' }" COPY = powershell -Command "Copy-Item" else PLATFORM = $(shell uname -s | tr '[:upper:]' '[:lower:]') @@ -50,7 +50,13 @@ setup: # 清理构建文件 .PHONY: clean clean: +ifeq ($(OS),Windows_NT) + $(call RMRF,$(DIST_DIR)) + $(call RMRF,$(BUILD_DIR)) + $(call RMRF,*.spec) +else $(RMRF) "$(DIST_DIR)" "$(BUILD_DIR)" *.spec +endif # 初始化配置文件 .PHONY: init-config From 79a6f781565de52a279ba1fcbbec0ba8cb74981e Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:31:50 +0800 Subject: [PATCH 10/33] fix: Update rsync upload command with remote host protocol prefix - Added `rsync://` protocol prefix to remote host configuration - Ensured compatibility with rsync server addressing - Maintained existing secure upload configuration --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index a70c99c..5238d15 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -86,6 +86,6 @@ jobs: switches: -tvzr --delete path: dist/ remote_path: /data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/ - remote_host: ${{ secrets.RSYNC_HOST }} + remote_host: rsync://${{ secrets.RSYNC_HOST }} remote_user: ${{ secrets.RSYNC_USER }} remote_key: ${{ secrets.RSYNC_PASSWORD }} \ No newline at end of file From 2635cc380efcbcd27c97bb9ba8c59264e29911c6 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:34:57 +0800 Subject: [PATCH 11/33] feat: Enhance cross-platform checksum generation in package workflow - Added platform-specific checksum generation for Linux and macOS - Updated workflow to use different checksum commands based on operating system - Maintained consistent SHA256 checksum file creation across platforms - Disabled fail-fast strategy to ensure all build targets are processed --- .github/workflows/package.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 5238d15..df8d52c 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -10,6 +10,7 @@ jobs: # 二进制文件构建任务 build-and-publish: strategy: + fail-fast: false matrix: include: - os: ubuntu-latest @@ -56,13 +57,20 @@ jobs: run: | make clean setup current - - name: Generate checksum (Unix) - if: runner.os != 'Windows' + - name: Generate checksum (Linux) + if: runner.os == 'Linux' shell: bash run: | cd dist sha256sum * > SHA256SUMS.txt + - name: Generate checksum (macOS) + if: runner.os == 'Darwin' + shell: bash + run: | + cd dist + shasum -a 256 * > SHA256SUMS.txt + - name: Generate checksum (Windows) if: runner.os == 'Windows' shell: pwsh From a22e423c684477a2bac8c1dbfd747c44891cc7f5 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:40:18 +0800 Subject: [PATCH 12/33] feat: Add cross-platform rsync deployment support for package workflow - Implemented platform-specific rsync deployment for Unix and Windows - Added rsync installation for Windows using Chocolatey - Created separate deployment steps for Unix and Windows environments - Improved password file handling with platform-specific approaches - Maintained secure upload configuration with error tolerance --- .github/workflows/package.yml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index df8d52c..dbee1bb 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -88,12 +88,27 @@ jobs: cd dist (Get-Content SHA256SUMS.txt) | Set-Content -Encoding utf8 SHA256SUMS.txt - - name: Deploy to rsync server - uses: Burnett01/rsync-deployments@6.0.0 - with: - switches: -tvzr --delete - path: dist/ - remote_path: /data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/ - remote_host: rsync://${{ secrets.RSYNC_HOST }} - remote_user: ${{ secrets.RSYNC_USER }} - remote_key: ${{ secrets.RSYNC_PASSWORD }} \ No newline at end of file + - name: Install rsync (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + choco install rsync + + - name: Deploy to rsync server (Unix) + if: runner.os != 'Windows' + shell: bash + env: + VERSION: ${{ env.VERSION }} + run: | + echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync.passwd && chmod 600 /tmp/rsync.passwd + rsync --password-file=/tmp/rsync.passwd -vzrt --progress dist/ "rsync://${{ secrets.RSYNC_USER }}@${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || true + + - name: Deploy to rsync server (Windows) + if: runner.os == 'Windows' + shell: pwsh + env: + VERSION: ${{ env.VERSION }} + RSYNC_PASSWORD: ${{ secrets.RSYNC_PASSWORD }} + run: | + $env:RSYNC_PASSWORD | Out-File -FilePath "$env:TEMP\rsync.passwd" -Encoding ASCII + rsync --password-file="$env:TEMP\rsync.passwd" -vzrt --progress dist/ "rsync://${{ secrets.RSYNC_USER }}@${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || exit 0 \ No newline at end of file From fd3c57159f980fe8cffb9a79aa535db47988d063 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:44:34 +0800 Subject: [PATCH 13/33] feat: Dynamically generate version from git tags in Makefile - Updated Makefile to extract version from git tags dynamically - Added cross-platform version detection for Windows and Unix-like systems - Implemented fallback to 'v0.0.0' if no valid tag is found - Removed hardcoded version number --- .github/workflows/package.yml | 8 ++++---- Makefile | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index dbee1bb..dac2eb1 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -62,14 +62,14 @@ jobs: shell: bash run: | cd dist - sha256sum * > SHA256SUMS.txt + sha256sum * > SHA256SUMS.linux.txt - name: Generate checksum (macOS) if: runner.os == 'Darwin' shell: bash run: | cd dist - shasum -a 256 * > SHA256SUMS.txt + shasum -a 256 * > SHA256SUMS.darwin.txt - name: Generate checksum (Windows) if: runner.os == 'Windows' @@ -78,7 +78,7 @@ jobs: cd dist Get-ChildItem -File | ForEach-Object { $hash = (Get-FileHash -Algorithm SHA256 $_.Name).Hash.ToLower() - "$hash $($_.Name)" | Out-File -Append -Encoding utf8 SHA256SUMS.txt + "$hash $($_.Name)" | Out-File -Append -Encoding utf8 SHA256SUMS.windows.txt } - name: Fix line endings (Windows) @@ -86,7 +86,7 @@ jobs: shell: pwsh run: | cd dist - (Get-Content SHA256SUMS.txt) | Set-Content -Encoding utf8 SHA256SUMS.txt + (Get-Content SHA256SUMS.windows.txt) | Set-Content -Encoding utf8 SHA256SUMS.windows.txt - name: Install rsync (Windows) if: runner.os == 'Windows' diff --git a/Makefile b/Makefile index 1d1e300..81e6c7a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,12 @@ # 定义变量 PACKAGE_NAME = tapflow -VERSION = 0.2.54 + +ifeq ($(OS),Windows_NT) + VERSION = $(shell powershell -Command "$$tag = git describe --tags; if ($$tag -match '^v\d+\.\d+\.\d+') { $$matches[0] } else { 'v0.0.0' }") +else + VERSION = $(shell git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' || echo v0.0.0) +endif + MAIN_ENTRY = tapflow/cli/tap.py DIST_DIR = dist BUILD_DIR = build From 961e00deccfc2d0e684eacdf2991f2396bea53de Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:48:43 +0800 Subject: [PATCH 14/33] chore: Update GitHub Actions checkout to fetch full git history - Added fetch-depth: 0 to actions/checkout to retrieve complete git history - Ensures all tags and commit history are available for version generation - Supports dynamic version extraction from git tags --- .github/workflows/package.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index dac2eb1..14a5b82 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -28,6 +28,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 # 获取完整的历史记录,包括所有标签 - name: Set up Python uses: actions/setup-python@v5 From bde866622b39ba94f10e2f755d418a04b651dddc Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:50:36 +0800 Subject: [PATCH 15/33] feat: Improve version extraction in GitHub Actions package workflow - Added cross-platform version detection for Windows and Unix-like systems - Implemented dynamic version extraction from git tags using shell and PowerShell commands - Provided fallback to '0.0.0' if no valid tag is found - Enhanced version generation logic in GitHub Actions workflow --- .github/workflows/package.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 14a5b82..da23a83 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -44,7 +44,12 @@ jobs: if [[ $GITHUB_REF == refs/tags/* ]]; then echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV else - echo "VERSION=latest" >> $GITHUB_ENV + if [[ "$RUNNER_OS" == "Windows" ]]; then + VERSION=$(powershell -Command "$$tag = git describe --tags; if ($$tag -match '^v\d+\.\d+\.\d+') { $$matches[0].substring(1) } else { '0.0.0' }") + else + VERSION=$(git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' | sed 's/^v//' || echo '0.0.0') + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV fi - name: Install make (Windows) From 80d25d851f741ae0f37ea697939a8e6327929476 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:52:28 +0800 Subject: [PATCH 16/33] refactor: Optimize version extraction in GitHub Actions workflow - Simplified version extraction script for Windows using PowerShell - Improved shell script for Unix-like systems - Ensured consistent version detection across platforms - Removed redundant shell commands and improved readability --- .github/workflows/package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index da23a83..5eb6841 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -39,18 +39,18 @@ jobs: - name: Extract version from tag id: get_version - shell: bash run: | if [[ $GITHUB_REF == refs/tags/* ]]; then echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV else if [[ "$RUNNER_OS" == "Windows" ]]; then - VERSION=$(powershell -Command "$$tag = git describe --tags; if ($$tag -match '^v\d+\.\d+\.\d+') { $$matches[0].substring(1) } else { '0.0.0' }") + powershell -Command "Write-Output \"VERSION=$((git describe --tags | Select-String -Pattern '^v\d+\.\d+\.\d+' | ForEach-Object { $_.Matches[0].Value.Substring(1) }) ?? '0.0.0')\"" >> $GITHUB_ENV else VERSION=$(git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' | sed 's/^v//' || echo '0.0.0') + echo "VERSION=$VERSION" >> $GITHUB_ENV fi - echo "VERSION=$VERSION" >> $GITHUB_ENV fi + shell: bash - name: Install make (Windows) if: runner.os == 'Windows' From f3b7bf2298aa7826bae0b347240925cafbd5190f Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:54:36 +0800 Subject: [PATCH 17/33] fix: Improve macOS checksum generation in package workflow - Updated macOS checksum generation script to handle file filtering - Prevented overwriting existing checksum file - Ensured only valid files are included in SHA256SUMS.darwin.txt - Enhanced robustness of checksum generation process --- .github/workflows/package.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 5eb6841..2ccb103 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -76,7 +76,11 @@ jobs: shell: bash run: | cd dist - shasum -a 256 * > SHA256SUMS.darwin.txt + for file in *; do + if [ -f "$file" ] && [ "$file" != "SHA256SUMS.darwin.txt" ]; then + shasum -a 256 "$file" >> SHA256SUMS.darwin.txt + fi + done - name: Generate checksum (Windows) if: runner.os == 'Windows' From 749c81635e0e22175c73576bed93fff761c836cb Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:58:01 +0800 Subject: [PATCH 18/33] fix: Refactor version extraction in Makefile and GitHub Actions workflow - Updated PowerShell script in Makefile to improve version tag extraction - Simplified version detection logic in GitHub Actions package workflow - Maintained consistent cross-platform version generation approach - Improved error handling and fallback mechanism for version extraction --- .github/workflows/package.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2ccb103..6052d94 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -44,7 +44,7 @@ jobs: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV else if [[ "$RUNNER_OS" == "Windows" ]]; then - powershell -Command "Write-Output \"VERSION=$((git describe --tags | Select-String -Pattern '^v\d+\.\d+\.\d+' | ForEach-Object { $_.Matches[0].Value.Substring(1) }) ?? '0.0.0')\"" >> $GITHUB_ENV + powershell -Command "$tag = git describe --tags; if ($tag -match '^v\d+\.\d+\.\d+') { $matches[0].Substring(1) } else { '0.0.0' }" >> $GITHUB_ENV else VERSION=$(git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' | sed 's/^v//' || echo '0.0.0') echo "VERSION=$VERSION" >> $GITHUB_ENV diff --git a/Makefile b/Makefile index 81e6c7a..d3cc778 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PACKAGE_NAME = tapflow ifeq ($(OS),Windows_NT) - VERSION = $(shell powershell -Command "$$tag = git describe --tags; if ($$tag -match '^v\d+\.\d+\.\d+') { $$matches[0] } else { 'v0.0.0' }") + VERSION = $(shell powershell -Command "$tag = git describe --tags; if ($tag -match '^v\d+\.\d+\.\d+') { $matches[0] } else { 'v0.0.0' }") else VERSION = $(shell git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' || echo v0.0.0) endif From efbc82162c1d667b8a50a627e3cc68e201d9152c Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 16:59:42 +0800 Subject: [PATCH 19/33] fix: Refine version extraction for Windows in Makefile and GitHub Actions - Updated PowerShell version extraction logic in Makefile - Simplified version tag parsing for Windows environments - Improved command structure for more reliable version detection - Maintained consistent cross-platform version generation approach --- .github/workflows/package.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 6052d94..9192d56 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -44,7 +44,7 @@ jobs: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV else if [[ "$RUNNER_OS" == "Windows" ]]; then - powershell -Command "$tag = git describe --tags; if ($tag -match '^v\d+\.\d+\.\d+') { $matches[0].Substring(1) } else { '0.0.0' }" >> $GITHUB_ENV + powershell -Command "Write-Output ('VERSION=' + (git describe --tags | Select-String -Pattern '^v\d+\.\d+\.\d+' | ForEach-Object { `$_.Matches[0].Value.Substring(1) } ))" >> $GITHUB_ENV else VERSION=$(git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' | sed 's/^v//' || echo '0.0.0') echo "VERSION=$VERSION" >> $GITHUB_ENV diff --git a/Makefile b/Makefile index d3cc778..a93354f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PACKAGE_NAME = tapflow ifeq ($(OS),Windows_NT) - VERSION = $(shell powershell -Command "$tag = git describe --tags; if ($tag -match '^v\d+\.\d+\.\d+') { $matches[0] } else { 'v0.0.0' }") + VERSION = v$(shell powershell -Command "(git describe --tags | Select-String -Pattern '^v\d+\.\d+\.\d+' | ForEach-Object { $$_.Matches[0].Value.Substring(1) } ) -replace '^\s*|\s*$$',''") else VERSION = $(shell git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' || echo v0.0.0) endif From d7e026a0fb5ffa3c8ed4968a3321706bc02f2f9a Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 17:03:49 +0800 Subject: [PATCH 20/33] refactor: Centralize version extraction in GitHub Actions workflow - Added new `get-version` job to extract version consistently across build matrix - Simplified version detection logic in build job - Removed redundant version extraction steps - Passed version as an input to build job using GitHub Actions outputs - Updated Makefile to use default version fallback --- .github/workflows/package.yml | 50 ++++++++++++++++++++--------------- Makefile | 8 +----- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 9192d56..5a58899 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -7,8 +7,30 @@ on: workflow_dispatch: # 允许手动触发 jobs: + # 获取版本号 + get-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.version }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get version + id: get_version + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + else + VERSION=$(git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' | sed 's/^v//' || echo '0.0.0') + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + # 二进制文件构建任务 build-and-publish: + needs: get-version strategy: fail-fast: false matrix: @@ -29,7 +51,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 0 # 获取完整的历史记录,包括所有标签 + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 @@ -37,21 +59,6 @@ jobs: python-version: '3.11' architecture: x64 - - name: Extract version from tag - id: get_version - run: | - if [[ $GITHUB_REF == refs/tags/* ]]; then - echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - else - if [[ "$RUNNER_OS" == "Windows" ]]; then - powershell -Command "Write-Output ('VERSION=' + (git describe --tags | Select-String -Pattern '^v\d+\.\d+\.\d+' | ForEach-Object { `$_.Matches[0].Value.Substring(1) } ))" >> $GITHUB_ENV - else - VERSION=$(git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' | sed 's/^v//' || echo '0.0.0') - echo "VERSION=$VERSION" >> $GITHUB_ENV - fi - fi - shell: bash - - name: Install make (Windows) if: runner.os == 'Windows' run: | @@ -61,8 +68,9 @@ jobs: shell: bash env: PYTHONPATH: ${{ github.workspace }} + VERSION: ${{ needs.get-version.outputs.version }} run: | - make clean setup current + make clean setup current VERSION=$VERSION - name: Generate checksum (Linux) if: runner.os == 'Linux' @@ -109,17 +117,17 @@ jobs: if: runner.os != 'Windows' shell: bash env: - VERSION: ${{ env.VERSION }} + VERSION: ${{ needs.get-version.outputs.version }} run: | echo '${{ secrets.RSYNC_PASSWORD }}' > /tmp/rsync.passwd && chmod 600 /tmp/rsync.passwd - rsync --password-file=/tmp/rsync.passwd -vzrt --progress dist/ "rsync://${{ secrets.RSYNC_USER }}@${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || true + rsync --password-file=/tmp/rsync.passwd -vzrt --progress dist/ "rsync://${{ secrets.RSYNC_USER }}@${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/$VERSION/" || true - name: Deploy to rsync server (Windows) if: runner.os == 'Windows' shell: pwsh env: - VERSION: ${{ env.VERSION }} + VERSION: ${{ needs.get-version.outputs.version }} RSYNC_PASSWORD: ${{ secrets.RSYNC_PASSWORD }} run: | $env:RSYNC_PASSWORD | Out-File -FilePath "$env:TEMP\rsync.passwd" -Encoding ASCII - rsync --password-file="$env:TEMP\rsync.passwd" -vzrt --progress dist/ "rsync://${{ secrets.RSYNC_USER }}@${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || exit 0 \ No newline at end of file + rsync --password-file="$env:TEMP\rsync.passwd" -vzrt --progress dist/ "rsync://${{ secrets.RSYNC_USER }}@${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/$VERSION/" || exit 0 \ No newline at end of file diff --git a/Makefile b/Makefile index a93354f..65a341c 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,6 @@ # 定义变量 PACKAGE_NAME = tapflow - -ifeq ($(OS),Windows_NT) - VERSION = v$(shell powershell -Command "(git describe --tags | Select-String -Pattern '^v\d+\.\d+\.\d+' | ForEach-Object { $$_.Matches[0].Value.Substring(1) } ) -replace '^\s*|\s*$$',''") -else - VERSION = $(shell git describe --tags | grep -o '^v[0-9]\+\.[0-9]\+\.[0-9]\+' || echo v0.0.0) -endif - +VERSION ?= 0.0.0 MAIN_ENTRY = tapflow/cli/tap.py DIST_DIR = dist BUILD_DIR = build From afa0b8065e3c4ff03df12c9879080cdfb472172d Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 17:11:11 +0800 Subject: [PATCH 21/33] fix: Correct version variable usage in rsync deployment step - Updated rsync deployment command to use `${{ env.VERSION }}` instead of `$VERSION` - Ensured consistent environment variable referencing in GitHub Actions workflow - Maintained cross-platform rsync deployment approach --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 5a58899..15bc9ea 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -130,4 +130,4 @@ jobs: RSYNC_PASSWORD: ${{ secrets.RSYNC_PASSWORD }} run: | $env:RSYNC_PASSWORD | Out-File -FilePath "$env:TEMP\rsync.passwd" -Encoding ASCII - rsync --password-file="$env:TEMP\rsync.passwd" -vzrt --progress dist/ "rsync://${{ secrets.RSYNC_USER }}@${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/$VERSION/" || exit 0 \ No newline at end of file + rsync --password-file="$env:TEMP\rsync.passwd" -vzrt --progress dist/ "rsync://${{ secrets.RSYNC_USER }}@${{ secrets.RSYNC_HOST }}/data/enterprise-artifact/gz/tapflow/${{ env.VERSION }}/" || exit 0 \ No newline at end of file From ff7ee9ef660fc1c918435691bc00ee30d048e163 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Fri, 14 Feb 2025 17:17:50 +0800 Subject: [PATCH 22/33] fix: Correct macOS runner condition in package workflow - Updated GitHub Actions workflow to use 'macOS' instead of 'Darwin' - Ensured consistent runner OS detection for macOS checksum generation - Maintained cross-platform compatibility in package workflow --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 15bc9ea..2098370 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -80,7 +80,7 @@ jobs: sha256sum * > SHA256SUMS.linux.txt - name: Generate checksum (macOS) - if: runner.os == 'Darwin' + if: runner.os == 'macOS' shell: bash run: | cd dist From 15562ccded45ed919f13547338143f50ee52d01f Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Mon, 17 Feb 2025 17:20:05 +0800 Subject: [PATCH 23/33] chore: Update GitHub Actions workflow runner to Ubuntu 20.04 - Replaced `ubuntu-latest` with `ubuntu-20.04` in package workflow - Maintained consistent runner configuration across jobs - Ensured stable build environment for Linux builds --- .github/workflows/package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2098370..bf9ed86 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -9,7 +9,7 @@ on: jobs: # 获取版本号 get-version: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 outputs: version: ${{ steps.get_version.outputs.version }} steps: @@ -35,7 +35,7 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-latest + - os: ubuntu-20.04 platform: linux arch: x86_64 - os: macos-latest From fac2808b6733f9b973d0ff18ac9502b532d82f26 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 15:39:26 +0800 Subject: [PATCH 24/33] chore: Enhance build matrix and platform configuration - Added CentOS 7 build configuration in GitHub Actions workflow - Updated Makefile to support optional platform and architecture variables - Improved cross-platform build and packaging flexibility - Enabled Docker-based build for CentOS 7 environment --- .github/workflows/package.yml | 18 ++++++++++++++++-- Makefile | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index bf9ed86..021cfc8 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -36,8 +36,12 @@ jobs: matrix: include: - os: ubuntu-20.04 - platform: linux + platform: ubuntu arch: x86_64 + - os: ubuntu-22.04 + platform: centos + arch: x86_64 + is_centos7: true - os: macos-latest platform: darwin arch: x86_64 @@ -69,8 +73,18 @@ jobs: env: PYTHONPATH: ${{ github.workspace }} VERSION: ${{ needs.get-version.outputs.version }} + PLATFORM: ${{ matrix.platform }} + ARCH: ${{ matrix.arch }} run: | - make clean setup current VERSION=$VERSION + if [ "${{ matrix.is_centos7 }}" = "true" ]; then + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace centos:7 /bin/bash -c ' + curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ + yum makecache && \ + yum install -y make python3 python3-pip && \ + PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} make clean setup current VERSION=${{ needs.get-version.outputs.version }}' + else + make clean setup current VERSION=$VERSION + fi - name: Generate checksum (Linux) if: runner.os == 'Linux' diff --git a/Makefile b/Makefile index 65a341c..cee4098 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ ifeq ($(OS),Windows_NT) RMRF = powershell -Command "if (Test-Path '$(1)') { Remove-Item -Recurse -Force '$(1)' }" COPY = powershell -Command "Copy-Item" else - PLATFORM = $(shell uname -s | tr '[:upper:]' '[:lower:]') - ARCH = $(shell uname -m) + PLATFORM ?= $(shell uname -s | tr '[:upper:]' '[:lower:]') + ARCH ?= $(shell uname -m) PYTHON = python3 PIP = pip3 CONFIG_DIR = $(HOME)/.tapflow From 99b36d058138eb98d2084e389c85c60b2ee14177 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 15:56:34 +0800 Subject: [PATCH 25/33] chore: Improve package workflow for CentOS 7 and checksum generation - Added `importlib-metadata` installation for CentOS 7 build - Updated checksum generation to use platform-specific filename - Enhanced build process for CentOS 7 environment --- .github/workflows/package.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 021cfc8..81715db 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -81,6 +81,7 @@ jobs: curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ yum makecache && \ yum install -y make python3 python3-pip && \ + pip3 install importlib-metadata && \ PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} make clean setup current VERSION=${{ needs.get-version.outputs.version }}' else make clean setup current VERSION=$VERSION @@ -91,7 +92,7 @@ jobs: shell: bash run: | cd dist - sha256sum * > SHA256SUMS.linux.txt + sha256sum * > SHA256SUMS.${{ matrix.platform }}.txt - name: Generate checksum (macOS) if: runner.os == 'macOS' From 3cfe70a8069f0e3391fdfd890b58758c1995b7d0 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 16:00:22 +0800 Subject: [PATCH 26/33] chore: Upgrade Python installation for CentOS 7 build environment - Replaced default Python with Python 3.8.12 from source - Added dependencies for Python compilation - Installed PyInstaller for build process - Updated workflow to use custom Python 3.8 installation - Configured pip and added necessary build tools --- .github/workflows/package.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 81715db..253178e 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -80,9 +80,17 @@ jobs: docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace centos:7 /bin/bash -c ' curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ yum makecache && \ - yum install -y make python3 python3-pip && \ - pip3 install importlib-metadata && \ - PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} make clean setup current VERSION=${{ needs.get-version.outputs.version }}' + yum install -y make gcc openssl-devel bzip2-devel libffi-devel wget && \ + wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz && \ + tar xzf Python-3.8.12.tgz && \ + cd Python-3.8.12 && \ + ./configure --enable-optimizations && \ + make altinstall && \ + cd .. && \ + rm -rf Python-3.8.12* && \ + python3.8 -m pip install --upgrade pip && \ + python3.8 -m pip install importlib-metadata pyinstaller==4.10 && \ + PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python3.8 make clean setup current VERSION=${{ needs.get-version.outputs.version }}' else make clean setup current VERSION=$VERSION fi From 45a80dc53932f7039bd10847bb05ef80c0e0eaad Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 16:03:44 +0800 Subject: [PATCH 27/33] chore: Simplify Python installation for CentOS 7 build environment - Replaced manual Python 3.8.12 compilation with SCL Python 3.8 - Streamlined package installation and environment setup - Reduced workflow complexity by using Software Collections Python - Updated build command to use system Python from SCL --- .github/workflows/package.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 253178e..e685b98 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -80,17 +80,13 @@ jobs: docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace centos:7 /bin/bash -c ' curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ yum makecache && \ - yum install -y make gcc openssl-devel bzip2-devel libffi-devel wget && \ - wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz && \ - tar xzf Python-3.8.12.tgz && \ - cd Python-3.8.12 && \ - ./configure --enable-optimizations && \ - make altinstall && \ - cd .. && \ - rm -rf Python-3.8.12* && \ - python3.8 -m pip install --upgrade pip && \ - python3.8 -m pip install importlib-metadata pyinstaller==4.10 && \ - PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python3.8 make clean setup current VERSION=${{ needs.get-version.outputs.version }}' + yum install -y make gcc && \ + yum install -y centos-release-scl && \ + yum install -y rh-python38 && \ + source /opt/rh/rh-python38/enable && \ + python -m pip install --upgrade pip && \ + python -m pip install importlib-metadata pyinstaller==4.10 && \ + PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python make clean setup current VERSION=${{ needs.get-version.outputs.version }}' else make clean setup current VERSION=$VERSION fi From 24e70bfeed89367c5a05d15face9b48e8ced4c8c Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 16:36:44 +0800 Subject: [PATCH 28/33] chore: Replace SCL Python with manual Python 3.8.12 installation in CentOS 7 workflow - Reverted to compiling Python 3.8.12 from source instead of using Software Collections - Added necessary dependencies for Python compilation - Installed Python 3.8.12 with optimizations - Created symlinks for python3 and pip3 - Updated build command to use manually installed Python 3.8 --- .github/workflows/package.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index e685b98..9dc4a97 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -80,13 +80,19 @@ jobs: docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace centos:7 /bin/bash -c ' curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ yum makecache && \ - yum install -y make gcc && \ - yum install -y centos-release-scl && \ - yum install -y rh-python38 && \ - source /opt/rh/rh-python38/enable && \ - python -m pip install --upgrade pip && \ - python -m pip install importlib-metadata pyinstaller==4.10 && \ - PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python make clean setup current VERSION=${{ needs.get-version.outputs.version }}' + yum install -y make gcc openssl-devel bzip2-devel libffi-devel wget && \ + wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz && \ + tar xzf Python-3.8.12.tgz && \ + cd Python-3.8.12 && \ + ./configure --enable-optimizations && \ + make altinstall && \ + cd .. && \ + rm -rf Python-3.8.12* && \ + ln -sf /usr/local/bin/python3.8 /usr/local/bin/python3 && \ + ln -sf /usr/local/bin/pip3.8 /usr/local/bin/pip3 && \ + python3 -m pip install --upgrade pip && \ + python3 -m pip install importlib-metadata pyinstaller==4.10 && \ + PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python3.8 make clean setup current VERSION=${{ needs.get-version.outputs.version }}' else make clean setup current VERSION=$VERSION fi From dae97ac6b3d0732b387995aa67a568165a67a46d Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 16:43:00 +0800 Subject: [PATCH 29/33] chore: Enhance Python 3.8.12 installation with SQLite support in CentOS 7 workflow - Added sqlite-devel package to Python compilation dependencies - Enabled SQLite extensions during Python configuration - Maintained optimized Python 3.8.12 installation process --- .github/workflows/package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 9dc4a97..13258e6 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -80,11 +80,11 @@ jobs: docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace centos:7 /bin/bash -c ' curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ yum makecache && \ - yum install -y make gcc openssl-devel bzip2-devel libffi-devel wget && \ + yum install -y make gcc openssl-devel bzip2-devel libffi-devel wget sqlite-devel && \ wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz && \ tar xzf Python-3.8.12.tgz && \ cd Python-3.8.12 && \ - ./configure --enable-optimizations && \ + ./configure --enable-optimizations --enable-loadable-sqlite-extensions && \ make altinstall && \ cd .. && \ rm -rf Python-3.8.12* && \ From 45e6142f2f3df477330c8614d23d0e8728cebdb9 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 16:49:11 +0800 Subject: [PATCH 30/33] chore: Improve Python 3.8.12 installation with shared library support - Added `--enable-shared` flag during Python configuration - Configured dynamic library path with `/etc/ld.so.conf.d/local.conf` - Ran `ldconfig` to update shared library cache - Maintained previous Python 3.8.12 installation optimizations --- .github/workflows/package.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 13258e6..6074e92 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -84,10 +84,12 @@ jobs: wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz && \ tar xzf Python-3.8.12.tgz && \ cd Python-3.8.12 && \ - ./configure --enable-optimizations --enable-loadable-sqlite-extensions && \ + ./configure --enable-optimizations --enable-loadable-sqlite-extensions --enable-shared && \ make altinstall && \ cd .. && \ rm -rf Python-3.8.12* && \ + echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf && \ + ldconfig && \ ln -sf /usr/local/bin/python3.8 /usr/local/bin/python3 && \ ln -sf /usr/local/bin/pip3.8 /usr/local/bin/pip3 && \ python3 -m pip install --upgrade pip && \ From 29427731acf0dcd0e5e3a4dc2441eebd2e74e724 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 16:55:33 +0800 Subject: [PATCH 31/33] chore: Enhance package workflow with automated checksum generation - Added SHA256SUMS generation for each platform in the build process - Implemented checksum file creation in the dist directory - Adjusted file ownership to maintain workflow consistency - Simplified checksum generation for different build environments --- .github/workflows/package.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 6074e92..96e1698 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -94,13 +94,17 @@ jobs: ln -sf /usr/local/bin/pip3.8 /usr/local/bin/pip3 && \ python3 -m pip install --upgrade pip && \ python3 -m pip install importlib-metadata pyinstaller==4.10 && \ - PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python3.8 make clean setup current VERSION=${{ needs.get-version.outputs.version }}' + PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python3.8 make clean setup current VERSION=${{ needs.get-version.outputs.version }} && \ + cd dist && \ + sha256sum * > SHA256SUMS.${{ matrix.platform }}.txt && \ + cd .. && \ + chown -R $(stat -c "%u:%g" /workspace) /workspace/dist' else make clean setup current VERSION=$VERSION fi - name: Generate checksum (Linux) - if: runner.os == 'Linux' + if: runner.os == 'Linux' && !matrix.is_centos7 shell: bash run: | cd dist From f64afaa86b182eaea344fa75b414fe13d4acdb2b Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 17:06:29 +0800 Subject: [PATCH 32/33] chore: Add urllib3 version constraint in package workflow - Installed urllib3 with version less than 2.0.0 to prevent potential compatibility issues - Ensured stable dependency management in the package build process --- .github/workflows/package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 96e1698..e62f328 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -93,6 +93,7 @@ jobs: ln -sf /usr/local/bin/python3.8 /usr/local/bin/python3 && \ ln -sf /usr/local/bin/pip3.8 /usr/local/bin/pip3 && \ python3 -m pip install --upgrade pip && \ + python3 -m pip install "urllib3<2.0.0" && \ python3 -m pip install importlib-metadata pyinstaller==4.10 && \ PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python3.8 make clean setup current VERSION=${{ needs.get-version.outputs.version }} && \ cd dist && \ From 70032e90795b5c6c15f9ace620a47d4f78f7e929 Mon Sep 17 00:00:00 2001 From: dreamcoin1998 Date: Wed, 19 Feb 2025 17:08:29 +0800 Subject: [PATCH 33/33] chore: Add CentOS 7 build target in Makefile and simplify GitHub Actions workflow - Created a new `centos7` Makefile target for CentOS 7 build process - Extracted Docker-based CentOS 7 build steps from GitHub Actions workflow - Simplified package workflow by referencing the new Makefile target - Maintained existing Python 3.8.12 installation and build configuration --- .github/workflows/package.yml | 24 +----------------------- Makefile | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index e62f328..da27252 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -77,29 +77,7 @@ jobs: ARCH: ${{ matrix.arch }} run: | if [ "${{ matrix.is_centos7 }}" = "true" ]; then - docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace centos:7 /bin/bash -c ' - curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ - yum makecache && \ - yum install -y make gcc openssl-devel bzip2-devel libffi-devel wget sqlite-devel && \ - wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz && \ - tar xzf Python-3.8.12.tgz && \ - cd Python-3.8.12 && \ - ./configure --enable-optimizations --enable-loadable-sqlite-extensions --enable-shared && \ - make altinstall && \ - cd .. && \ - rm -rf Python-3.8.12* && \ - echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf && \ - ldconfig && \ - ln -sf /usr/local/bin/python3.8 /usr/local/bin/python3 && \ - ln -sf /usr/local/bin/pip3.8 /usr/local/bin/pip3 && \ - python3 -m pip install --upgrade pip && \ - python3 -m pip install "urllib3<2.0.0" && \ - python3 -m pip install importlib-metadata pyinstaller==4.10 && \ - PLATFORM=${{ matrix.platform }} ARCH=${{ matrix.arch }} PYTHON=python3.8 make clean setup current VERSION=${{ needs.get-version.outputs.version }} && \ - cd dist && \ - sha256sum * > SHA256SUMS.${{ matrix.platform }}.txt && \ - cd .. && \ - chown -R $(stat -c "%u:%g" /workspace) /workspace/dist' + make centos7 VERSION=$VERSION else make clean setup current VERSION=$VERSION fi diff --git a/Makefile b/Makefile index cee4098..35d6d46 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ VERSION ?= 0.0.0 MAIN_ENTRY = tapflow/cli/tap.py DIST_DIR = dist BUILD_DIR = build +DOCKER_CENTOS7_CMD = docker run --rm -v $(shell pwd):/workspace -w /workspace centos:7 /bin/bash -c # 检测操作系统 ifeq ($(OS),Windows_NT) @@ -128,4 +129,31 @@ current: init-config --hidden-import charset_normalizer \ --log-level ERROR \ --onefile \ - $(MAIN_ENTRY) \ No newline at end of file + $(MAIN_ENTRY) + +# CentOS 7构建目标 +.PHONY: centos7 +centos7: + $(DOCKER_CENTOS7_CMD) '\ + curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ + yum makecache && \ + yum install -y make gcc openssl-devel bzip2-devel libffi-devel wget sqlite-devel && \ + wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz && \ + tar xzf Python-3.8.12.tgz && \ + cd Python-3.8.12 && \ + ./configure --enable-optimizations --enable-loadable-sqlite-extensions --enable-shared && \ + make altinstall && \ + cd .. && \ + rm -rf Python-3.8.12* && \ + echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf && \ + ldconfig && \ + ln -sf /usr/local/bin/python3.8 /usr/local/bin/python3 && \ + ln -sf /usr/local/bin/pip3.8 /usr/local/bin/pip3 && \ + python3 -m pip install --upgrade pip && \ + python3 -m pip install "urllib3<2.0.0" && \ + python3 -m pip install importlib-metadata pyinstaller==4.10 && \ + PLATFORM=centos ARCH=x86_64 PYTHON=python3.8 make clean setup current VERSION=$(VERSION) && \ + cd dist && \ + sha256sum * > SHA256SUMS.centos.txt && \ + cd .. && \ + chown -R $(shell id -u):$(shell id -g) dist' \ No newline at end of file