Compare commits
6 Commits
3510024e99
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 21c7cf2924 | |||
| c1f6ca628e | |||
| 19b1ec5f3f | |||
| 9e64d298fc | |||
| cb4aa1c860 | |||
| 407b63e45b |
@@ -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_runner(Gitea 没有官方 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
|
|
||||||
|
|||||||
@@ -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
@@ -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
|
||||||
- 游戏客户端通常以管理员权限运行,本工具必须以同等权限运行才能检测到游戏进程
|
- 游戏客户端通常以管理员权限运行,本工具必须以同等权限运行才能检测到游戏进程
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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 Actions(windows-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),无需本地操作。
|
||||||
|
|
||||||
## 免责声明
|
## 免责声明
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user