Compare commits

...

6 Commits

Author SHA1 Message Date
zhengchen.tao 21c7cf2924 docs(readme): zip 内含说明加上 README.en.md
跟上一笔 c1f6ca6 (release.yml 加 Copy-Item README.en.md release/)
保持同步:用户解压后会看到两份 README,README.md 里也应该列上。

下次发版起 zip 实际就是这样;历史 release 仅含中文 README 不补。
2026-05-20 11:50:41 +08:00
zhengchen.tao c1f6ca628e ci(release): zip 内也带上 README.en.md
之前 release.yml 只 Copy-Item README.md release/,加了英文 README 之后
国外用户解压看到的还是中文,跟 README.en.md 初衷矛盾。

用 if (Test-Path) 保守加入:历史 tag 没 README.en.md 的话不会让 build
挂掉(虽然这个 workflow 只跑新 tag,但留个 future-proof 兜底)。

下次发版生效,历史 release 不补。
2026-05-20 11:30:01 +08:00
zhengchen.tao 19b1ec5f3f docs(readme): Releases 改回 GitHub 为主、Gitea 作镜像
回退 9e64d29 把方向搞反的部分:GitHub Releases 是 canonical 主发布
(action-gh-release@v2 一手做的),Gitea 是 mirror 步骤(走 Gitea API
PowerShell 同步,有 GITEA_TOKEN 才执行)。以 GitHub 为对外主推。

- 下载段:GitHub Releases 作主入口,加一句"国内慢可走 Gitea 镜像"
- 自行构建段:如实写"GitHub Actions 构建 → GitHub Releases 发布
  → Gitea API 镜像 zip"三步
- README.en.md 同步
2026-05-20 10:50:51 +08:00
zhengchen.tao 9e64d298fc docs(readme): 加 i18n 切换 + 新增英文版 + Releases 统一指向 Gitea
- 顶部加'简体中文 | English'切换 header
- 下载链路统一指 Gitea Releases:Gitea 是 source of truth(推 GitHub
  靠 push mirror 兜底),不再列 GitHub Releases 让外部读者多一跳
- 自行构建段如实写'GitHub Actions 构建 → Gitea API 同步发布':build
  在 windows-latest 跑 PyInstaller,然后由 sync step 把 artifact
  推到 Gitea Releases(.github/workflows/release.yml + .gitea
  /workflows/release.yml noop 占位)
- 新增 README.en.md
2026-05-20 10:33:28 +08:00
zhengchen.tao cb4aa1c860 chore: 清理 Gitea Actions 残留的 UI 痕迹
两处治理之前 Gitea workflow 删除后的副作用:

- 新增 .gitea/workflows/release.yml 占位 noop:上一版同名 workflow
  删除后 Gitea sidebar 仍残留 release.yml 项且 workflow_dispatch 可点
  但无 runner 匹配。换成一个真实存在但什么也不做的 workflow 接管该
  sidebar 项,并在内容里说明真实 release 流程在 GitHub 一侧
- .github/workflows/release.yml 末尾追加一步:build + mirror 完成
  后调用 Gitea statuses API,给 GITHUB_SHA 打 state=success 的
  commit status,context 与 Gitea Actions 当年用的一致
  ("release / build (push)")。Gitea UI 显示每 context 的最新状态,
  这一步可覆盖之前 cancelled 状态在 release 页面留下的红叉
2026-05-07 15:13:26 +08:00
zhengchen.tao 407b63e45b feat: GitHub Actions 构建后同步发布到 Gitea Releases
release / build (push) Cleared cancelled status from deprecated Gitea Actions runs
构建只在 GitHub windows-latest 上跑一次,产物通过 Gitea REST API 上传到
Gitea Releases,让国内无法访问 GitHub 的用户也能下载到 exe。

- .github/workflows/release.yml: 新增 Mirror release to Gitea 步骤,
  调用 /api/v1/repos/.../releases 创建发布并上传 zip 资产;
  GITEA_TOKEN 未配置时仅警告跳过,不阻断 GitHub release
- .gitea/workflows/release.yml: 删除。Gitea NAS 上的 Linux runner 无法
  交叉编译 Windows exe,本仓库不再使用 Gitea Actions
- README: 在下载步骤列出 Gitea / GitHub 双下载渠道
- CHANGELOG: v0.1.0 条目同步更新
2026-05-07 14:54:43 +08:00
5 changed files with 160 additions and 76 deletions
+18 -72
View File
@@ -1,79 +1,25 @@
name: release # 此文件不执行任何实际逻辑,仅用于占位。
#
# Why
# - Release 流程已迁到 GitHub Actions(见 .github/workflows/release.yml),
# 构建完成后通过 Gitea API 同步发布到 Gitea Releases
# - 上一版 Gitea workflow 删除后,Gitea Actions 的 workflow 注册表
# 不会自动清理,导致 sidebar 仍残留 release.yml 项 + workflow_dispatch
# 按钮可点但无 runner 匹配
# - 用一个 noop workflow "接管" 同名 sidebar 项,让手动触发能跑通
# 并清楚说明 release 流程在 GitHub 那边
name: placeholder (release pipeline lives on GitHub Actions)
on: on:
push:
tags:
- 'v*'
workflow_dispatch: workflow_dispatch:
inputs:
tag:
description: 'Release tag, 例如 v0.1.0(会自动创建 tag 并发布 release'
required: true
type: string
jobs: jobs:
build: noop:
# 需要一台带 Windows 的自托管 act_runnerGitea 没有官方 hosted Windows runner runs-on: ubuntu-latest
# 默认按 act_runner 常见标签 windows-latest;按你的 runner 实际 label 调整
runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v4 - name: Explain
- name: Resolve release tag
shell: pwsh
run: | run: |
if ($env:GITHUB_EVENT_NAME -eq 'workflow_dispatch') { echo "本仓库的 release 流程在 GitHub Actions 上执行。"
$t = '${{ inputs.tag }}' echo "构建完成后通过 Gitea API 同步到 Gitea Releases。"
} else { echo "本 workflow 仅为占位,不构建任何产物。"
$t = $env:GITHUB_REF_NAME
}
echo "RELEASE_TAG=$t" >> $env:GITHUB_ENV
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Build exe
run: pyinstaller --onefile --uac-admin --console --name df-scope-hold script.py
- name: Package release zip
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path release | Out-Null
Copy-Item dist/df-scope-hold.exe release/
Copy-Item config.ini release/
Copy-Item README.md release/
Compress-Archive -Path release/* -DestinationPath "df-scope-hold-$env:RELEASE_TAG.zip" -Force
echo "ASSET_ZIP=df-scope-hold-$env:RELEASE_TAG.zip" >> $env:GITHUB_ENV
- name: Upload workflow artifact
uses: actions/upload-artifact@v3
with:
name: df-scope-hold-${{ env.RELEASE_TAG }}
path: ${{ env.ASSET_ZIP }}
- name: Extract release notes from CHANGELOG.md
shell: pwsh
run: |
$content = Get-Content CHANGELOG.md -Raw
$escaped = [regex]::Escape($env:RELEASE_TAG)
$pattern = "(?ms)^## \[$escaped\].*?(?=^## |\Z)"
$m = [regex]::Match($content, $pattern)
if ($m.Success) {
$body = ($m.Value -replace '^## .*\r?\n', '').Trim()
} else {
$body = "Release $env:RELEASE_TAG"
}
$date = [DateTime]::UtcNow.ToString('yyyy-MM-dd')
$body = "**发布日期**: $date (UTC)`n`n" + $body
Set-Content -Path release-notes.md -Value $body -Encoding utf8
- name: Create Gitea Release
uses: akkuman/gitea-release-action@v1
with:
tag_name: ${{ env.RELEASE_TAG }}
files: ${{ env.ASSET_ZIP }}
body_path: release-notes.md
+55
View File
@@ -48,6 +48,7 @@ jobs:
Copy-Item dist/df-scope-hold.exe release/ Copy-Item dist/df-scope-hold.exe release/
Copy-Item config.ini release/ Copy-Item config.ini release/
Copy-Item README.md release/ Copy-Item README.md release/
if (Test-Path README.en.md) { Copy-Item README.en.md release/ }
Compress-Archive -Path release/* -DestinationPath "df-scope-hold-$env:RELEASE_TAG.zip" -Force Compress-Archive -Path release/* -DestinationPath "df-scope-hold-$env:RELEASE_TAG.zip" -Force
echo "ASSET_ZIP=df-scope-hold-$env:RELEASE_TAG.zip" >> $env:GITHUB_ENV echo "ASSET_ZIP=df-scope-hold-$env:RELEASE_TAG.zip" >> $env:GITHUB_ENV
@@ -79,3 +80,57 @@ jobs:
tag_name: ${{ env.RELEASE_TAG }} tag_name: ${{ env.RELEASE_TAG }}
files: ${{ env.ASSET_ZIP }} files: ${{ env.ASSET_ZIP }}
body_path: release-notes.md body_path: release-notes.md
- name: Mirror release to Gitea
shell: pwsh
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_URL: https://git.zhengchentao.win
GITEA_OWNER: zhengchen.tao
GITEA_REPO: df-scope-hold
run: |
if (-not $env:GITEA_TOKEN) {
Write-Warning "secrets.GITEA_TOKEN 未配置,跳过 Gitea release 同步"
exit 0
}
$headers = @{ Authorization = "token $env:GITEA_TOKEN" }
$baseUrl = "$env:GITEA_URL/api/v1/repos/$env:GITEA_OWNER/$env:GITEA_REPO"
# 同 tag 已存在则先删(含其 assets),允许 re-run 覆盖发布
try {
$existing = Invoke-RestMethod -Method Get -Uri "$baseUrl/releases/tags/$env:RELEASE_TAG" -Headers $headers -ErrorAction Stop
Write-Host "覆盖已存在的 Gitea release id=$($existing.id)"
Invoke-RestMethod -Method Delete -Uri "$baseUrl/releases/$($existing.id)" -Headers $headers | Out-Null
} catch {
if ($_.Exception.Response.StatusCode.value__ -ne 404) { throw }
}
# 创建 release。tag 不存在时 Gitea 按 target_commitish 自动建 tag
$bodyContent = Get-Content release-notes.md -Raw
$payload = @{
tag_name = $env:RELEASE_TAG
name = $env:RELEASE_TAG
body = $bodyContent
draft = $false
prerelease = $false
target_commitish = $env:GITHUB_SHA
} | ConvertTo-Json
$release = Invoke-RestMethod -Method Post -Uri "$baseUrl/releases" -Headers $headers -ContentType 'application/json' -Body $payload
Write-Host "已创建 Gitea release id=$($release.id)"
# 上传 zip 资产
$assetName = [uri]::EscapeDataString($env:ASSET_ZIP)
Invoke-RestMethod -Method Post -Uri "$baseUrl/releases/$($release.id)/assets?name=$assetName" -Headers $headers -Form @{ attachment = Get-Item $env:ASSET_ZIP } | Out-Null
Write-Host "已上传 $env:ASSET_ZIP 到 Gitea release"
# 给同 SHA 打一条 success commit status,覆盖 Gitea Actions 历史残留的 cancelled
# 状态(Gitea release 页会沿 tag→commit 把 commit status badge 显示出来)
$statusPayload = @{
state = "success"
context = "release / build (push)"
description = "Built and mirrored from GitHub Actions"
target_url = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID"
} | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "$baseUrl/statuses/$env:GITHUB_SHA" -Headers $headers -ContentType 'application/json' -Body $statusPayload | Out-Null
Write-Host "已为 $env:GITHUB_SHA 打 success commit status"
+1 -1
View File
@@ -15,7 +15,7 @@
- 进程门控:仅在目标游戏进程运行时激活监听,游戏关闭自动停止,重启自动恢复 - 进程门控:仅在目标游戏进程运行时激活监听,游戏关闭自动停止,重启自动恢复
- `config.ini` 配置文件,可自定义按键、按键延迟(毫秒)、目标进程名 - `config.ini` 配置文件,可自定义按键、按键延迟(毫秒)、目标进程名
- Windows 单 exe 分发,内嵌 UAC manifest,双击自动请求管理员权限 - Windows 单 exe 分发,内嵌 UAC manifest,双击自动请求管理员权限
- GitHub / Gitea Actions 自动构建并发布 release zip含 exe + 默认 config.ini - GitHub Actions 自动构建 Windows exe,构建完成后同时发布到 GitHub Releases 与 Gitea Releases,方便不同网络环境下载(zip含 exe + 默认 config.ini + README
### Notes ### Notes
- 游戏客户端通常以管理员权限运行,本工具必须以同等权限运行才能检测到游戏进程 - 游戏客户端通常以管理员权限运行,本工具必须以同等权限运行才能检测到游戏进程
+79
View File
@@ -0,0 +1,79 @@
# df-scope-hold
[简体中文](README.md) | English
Auto-hold-breath helper for Delta Force — while you hold the right mouse
button, the tool presses a configurable key (default `F12`) and releases it
when you let go. Aim with right-click only; no extra key press needed.
## How it works
Pure local mouse→keyboard mapping. The script listens for right-mouse-button
events and presses/releases your configured "hold breath" key in sync. It
activates only while the game process is running. **No game memory is read,
no game files are modified, no game-server traffic is involved** — the
behavior is equivalent to a hardware mouse macro.
The in-game "hold breath" binding must be set to **hold mode**, not toggle
mode, or the simulated key release on right-mouse-up will get out of sync
with the game's scope state.
## Usage
1. **Bind "hold breath" in-game** to a key that does not conflict with other
actions (e.g. `F12`).
2. **Download** the latest `df-scope-hold-vX.X.X.zip` from [GitHub Releases](https://github.com/ZhengchenTao/df-scope-hold/releases) and unzip anywhere. If GitHub is slow in your region, a mirror is available at [Gitea Releases](https://git.zhengchentao.win/zhengchen.tao/df-scope-hold/releases) (auto-synced from each GitHub release).
3. **Edit `config.ini`** so `key` matches the in-game binding.
4. **Run `df-scope-hold.exe`**. UAC will prompt for admin privileges — accept,
as the anti-cheat-protected game process is otherwise undetectable.
```ini
[config]
key = f12 ; must match in-game binding
delay_press = 5 ; ms between RMB-down and simulated key-down
program_running = DeltaForceClient-Win64-Shipping.exe ; game process name (case-sensitive)
```
Press `Ctrl+C` in the console to exit.
## Runtime
Single Windows `.exe` (~10 MB), built with PyInstaller — bundles the Python
runtime and dependencies (`pynput`, `psutil`). No Python install required.
Verified on Windows only (the Delta Force client is Windows-exclusive).
## From source
```bash
pip install -r requirements.txt
python script.py
```
Requires Python 3.10+. For day-to-day use, just download a release.
## Build
```bash
pip install -r requirements.txt
pyinstaller --onefile --uac-admin --console --name df-scope-hold script.py
```
Output at `dist/df-scope-hold.exe`. GitHub Actions builds on `windows-latest`
(see `.github/workflows/release.yml`) when you push a `v*` tag, publishes the
zip to [GitHub Releases](https://github.com/ZhengchenTao/df-scope-hold/releases),
and mirrors it to [Gitea Releases](https://git.zhengchentao.win/zhengchen.tao/df-scope-hold/releases)
via the Gitea API — no local build needed.
## Disclaimer
- This is a purely local mouse→keyboard mapping tool, functionally identical
to the macro feature of any gaming mouse.
- That said, the game publisher's policy on third-party input tools may
change. **Any consequences from using this tool (including but not limited
to account bans) are at the user's own risk.**
- For personal use and learning only. Do not use in ranked / competitive play.
## License
MIT
+7 -3
View File
@@ -1,5 +1,7 @@
# df-scope-hold # df-scope-hold
简体中文 | [English](README.en.md)
三角洲行动(Delta Force)开镜自动屏息小工具——按住鼠标右键时自动按下指定按键(默认 `F12`),松开时释放。让你只用右键瞄准就能稳枪,不必再额外按一个键。 三角洲行动(Delta Force)开镜自动屏息小工具——按住鼠标右键时自动按下指定按键(默认 `F12`),松开时释放。让你只用右键瞄准就能稳枪,不必再额外按一个键。
## 工作原理 ## 工作原理
@@ -18,11 +20,13 @@
### 2. 下载并解压 ### 2. 下载并解压
本仓库 [Releases](../../releases) 页面下载最新的 `df-scope-hold-vX.X.X.zip`,解压到任意目录,里面包含: [GitHub Releases](https://github.com/ZhengchenTao/df-scope-hold/releases) 下载最新的 `df-scope-hold-vX.X.X.zip`,解压到任意目录。国内访问慢的话可走 [Gitea Releases](https://git.zhengchentao.win/zhengchen.tao/df-scope-hold/releases)GitHub 同 tag 自动同步过来的镜像)。
zip 内含:
- `df-scope-hold.exe`:主程序(已内嵌管理员权限 manifest,双击即弹 UAC - `df-scope-hold.exe`:主程序(已内嵌管理员权限 manifest,双击即弹 UAC
- `config.ini`:默认配置 - `config.ini`:默认配置
- `README.md`:本说明 - `README.md` / `README.en.md`:中英两版说明
### 3. 修改配置文件 ### 3. 修改配置文件
@@ -71,7 +75,7 @@ pip install -r requirements.txt
pyinstaller --onefile --uac-admin --console --name df-scope-hold script.py pyinstaller --onefile --uac-admin --console --name df-scope-hold script.py
``` ```
产物在 `dist/df-scope-hold.exe`。仓库已配置 GitHub / Gitea Actions,推 `v*` tag 后自动构建并发布到 Releases,无需本地操作。 产物在 `dist/df-scope-hold.exe`。仓库已配置 GitHub Actionswindows-latest 跑 PyInstaller,详见 `.github/workflows/release.yml`),推 `v*` tag 后自动构建并发布到 [GitHub Releases](https://github.com/ZhengchenTao/df-scope-hold/releases),同时通过 Gitea API 把 zip 镜像到 [Gitea Releases](https://git.zhengchentao.win/zhengchen.tao/df-scope-hold/releases),无需本地操作。
## 免责声明 ## 免责声明