From 876b2c72bc1577b56724dfabbcf6ad65cae4a56c Mon Sep 17 00:00:00 2001 From: engelgardt Date: Mon, 1 Jun 2026 12:57:28 +0300 Subject: [PATCH] chore: cut GitHub, make netswitch Gitea-only - relink README/CHANGELOG/pyproject/SECURITY to git.engelgardt23.ru - update-check + badges point to Gitea; rename GITHUB_REPO -> REPO - port CI to .gitea/workflows (self-contained, publishes Gitea release) - remove .github (workflow + issue templates); drop made-by lines --- {.github => .gitea}/workflows/release.yml | 48 ++++++++++++------- .github/ISSUE_TEMPLATE/bug_report.yml | 55 ---------------------- .github/ISSUE_TEMPLATE/config.yml | 5 -- .github/ISSUE_TEMPLATE/feature_request.yml | 23 --------- .gitignore | 2 +- CHANGELOG.md | 20 ++++---- CONTRIBUTING.md | 11 ++--- README.md | 8 ++-- README.ru.md | 8 ++-- SECURITY.md | 6 +-- pyproject.toml | 4 +- src/netswitch/__init__.py | 3 +- src/netswitch/app.py | 4 +- src/netswitch/update_check.py | 4 +- 14 files changed, 62 insertions(+), 139 deletions(-) rename {.github => .gitea}/workflows/release.yml (54%) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml diff --git a/.github/workflows/release.yml b/.gitea/workflows/release.yml similarity index 54% rename from .github/workflows/release.yml rename to .gitea/workflows/release.yml index 8aacf49..e17cb65 100644 --- a/.github/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -8,24 +8,30 @@ on: permissions: contents: write +# Self-contained: no external (GitHub-hosted) actions. Runs on a self-hosted +# Windows runner (label `windows`) that already has Python 3.12 on PATH. jobs: build: - runs-on: windows-latest + runs-on: windows steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' + - name: Checkout repository at tag + shell: pwsh + env: + TOKEN: ${{ github.token }} + run: | + $base = "${{ github.server_url }}" -replace '^https://', '' + $url = "https://oauth2:$env:TOKEN@$base/${{ github.repository }}.git" + git clone --depth 1 --branch "$env:GITHUB_REF_NAME" $url . - name: Install build dependencies run: python -m pip install --upgrade pip pyinstaller rich - name: Resolve version from tag id: ver - shell: bash - run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + shell: pwsh + run: | + $v = "$env:GITHUB_REF_NAME" -replace '^v', '' + "version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 - name: Build executable run: python -m PyInstaller --onefile --uac-admin --console --name netswitch --icon assets/icon.ico --paths src netswitch-launcher.py @@ -39,7 +45,6 @@ jobs: Copy-Item dist/netswitch.exe $folder/ @" netswitch v$ver - portable edition - made by engelgardt Quickly set a Windows network adapter to a static IP or back to DHCP. @@ -66,10 +71,19 @@ jobs: "$hash $zip" | Out-File -FilePath "$zip.sha256" -Encoding ASCII -NoNewline Get-Content "$zip.sha256" - - name: Create release - uses: softprops/action-gh-release@v2 - with: - files: | - netswitch-portable-v${{ steps.ver.outputs.version }}.zip - netswitch-portable-v${{ steps.ver.outputs.version }}.zip.sha256 - generate_release_notes: true + - name: Publish Gitea release + shell: pwsh + env: + TOKEN: ${{ github.token }} + run: | + $ver = '${{ steps.ver.outputs.version }}' + $tag = "v$ver" + $api = "${{ github.server_url }}/api/v1/repos/${{ github.repository }}" + $hdr = @{ Authorization = "token $env:TOKEN" } + $body = @{ tag_name = $tag; name = $tag; draft = $false; prerelease = $false } | ConvertTo-Json + $rel = Invoke-RestMethod -Method Post -Uri "$api/releases" -Headers $hdr -ContentType 'application/json' -Body $body + $rid = $rel.id + foreach ($f in @("netswitch-portable-v$ver.zip", "netswitch-portable-v$ver.zip.sha256")) { + curl.exe -s -H "Authorization: token $env:TOKEN" -F "attachment=@$f" "$api/releases/$rid/assets?name=$f" | Out-Null + Write-Host "uploaded $f" + } diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 6eab4ce..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Bug report -description: Something doesn't work as expected -labels: ["bug"] -body: - - type: input - id: version - attributes: - label: Version - description: Visible in the startup banner. - placeholder: v1.0.0 - validations: - required: true - - - type: textarea - id: steps - attributes: - label: Steps to reproduce - placeholder: | - 1. ... - 2. ... - 3. ... - validations: - required: true - - - type: textarea - id: expected - attributes: - label: What you expected to happen - validations: - required: true - - - type: textarea - id: actual - attributes: - label: What actually happened - description: Paste any error output verbatim. Screenshots are welcome. - validations: - required: true - - - type: input - id: os - attributes: - label: Windows version - placeholder: e.g. Windows 11 24H2 - - - type: input - id: adapter - attributes: - label: Adapter (if relevant) - placeholder: e.g. Realtek USB GbE Family Controller - - - type: textarea - id: extra - attributes: - label: Anything else? diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 6dbd167..0000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Security vulnerability - url: https://github.com/Engelgardt23/netswitch/security/advisories/new - about: Please report security issues privately via GitHub Security Advisories — not as a public issue. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index 48f565a..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Feature request -description: Suggest a new feature or an improvement -labels: ["enhancement"] -body: - - type: textarea - id: motivation - attributes: - label: What's the use case? - description: What are you trying to do, and why is the current behavior not enough? - validations: - required: true - - - type: textarea - id: proposal - attributes: - label: Proposed solution - validations: - required: true - - - type: textarea - id: alternatives - attributes: - label: Alternatives considered diff --git a/.gitignore b/.gitignore index e160ba9..9200062 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ builds/ # Legacy staging folders (kept for compatibility with old checkouts) portable-v*/ -# Stray standalone exe (we never commit binaries — they live in GitHub releases) +# Stray standalone exe (we never commit binaries — they live in Gitea releases) *.exe # Local backup of release archives (kept locally for history, not in repo) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6c7629..bbcda2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and ### Changed - **Rewrote netswitch in Python** (was PowerShell + ps2exe). The single-file `.ps1` script is gone, replaced by a small `netswitch/` package (`app.py`, `config.py`, `i18n.py`, `network.py`, `platform_win.py`, `update_check.py`) that mirrors the layout used by `dhcpsrv`. CI now builds via PyInstaller instead of ps2exe. - Output is now a Rich-styled console (coloured banner, current-config table) instead of plain `Write-Host`. -- The `Update available (vX.Y.Z)` notice in the header is a clickable terminal hyperlink to the GitHub releases page (OSC 8). Modern terminals render it as a link; older consoles show plain text. +- The `Update available (vX.Y.Z)` notice in the header is a clickable terminal hyperlink to the releases page (OSC 8). Modern terminals render it as a link; older consoles show plain text. ### Removed - `src/netswitch.ps1` and the ps2exe build step. If you specifically need a tiny PowerShell version, check out tag `v1.1.0`. @@ -35,19 +35,19 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and ## [1.0.0] - 2026-05-16 ### Added -- First public release on GitHub. +- First public release. - Portable `.exe` (~30 KB) built from PowerShell via ps2exe. - Self-elevation through UAC. - Physical wired NIC filter — Wi-Fi, VPN, virtual, Hyper-V, VMware, VirtualBox, TAP/TUN, WireGuard, OpenVPN, Tailscale, ZeroTier, Bluetooth, Loopback and WAN Miniport adapters are hidden from the picker. - Two modes: **Static** (default `10.10.10.1/24`, optional gateway) and **DHCP**. - Current IPv4 configuration is printed after the change. -- Auto-update check on startup: polls GitHub `/releases/latest` with a 3-second timeout and offers to open the download page if a newer version exists. Silent on offline / API errors. +- Auto-update check on startup: polls the Gitea instance `/releases/latest` with a 3-second timeout and offers to open the download page if a newer version exists. Silent on offline / API errors. - MIT licensed. -[Unreleased]: https://github.com/Engelgardt23/netswitch/compare/v1.2.0...HEAD -[1.2.0]: https://github.com/Engelgardt23/netswitch/compare/v1.1.0...v1.2.0 -[1.1.0]: https://github.com/Engelgardt23/netswitch/compare/v1.0.3...v1.1.0 -[1.0.3]: https://github.com/Engelgardt23/netswitch/compare/v1.0.2...v1.0.3 -[1.0.2]: https://github.com/Engelgardt23/netswitch/compare/v1.0.1...v1.0.2 -[1.0.1]: https://github.com/Engelgardt23/netswitch/compare/v1.0.0...v1.0.1 -[1.0.0]: https://github.com/Engelgardt23/netswitch/releases/tag/v1.0.0 +[Unreleased]: https://git.engelgardt23.ru/engel/netswitch/compare/v1.2.0...HEAD +[1.2.0]: https://git.engelgardt23.ru/engel/netswitch/compare/v1.1.0...v1.2.0 +[1.1.0]: https://git.engelgardt23.ru/engel/netswitch/compare/v1.0.3...v1.1.0 +[1.0.3]: https://git.engelgardt23.ru/engel/netswitch/compare/v1.0.2...v1.0.3 +[1.0.2]: https://git.engelgardt23.ru/engel/netswitch/compare/v1.0.1...v1.0.2 +[1.0.1]: https://git.engelgardt23.ru/engel/netswitch/compare/v1.0.0...v1.0.1 +[1.0.0]: https://git.engelgardt23.ru/engel/netswitch/releases/tag/v1.0.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2a06c3e..e2fb1f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,9 +6,8 @@ ``` netswitch/ -├── .github/ -│ ├── workflows/release.yml ← CI: tag-driven build + GitHub Release -│ └── ISSUE_TEMPLATE/ ← bug / feature / security routing +├── .gitea/ +│ └── workflows/release.yml ← CI: tag-driven build + Gitea Release ├── src/ │ └── netswitch.ps1 ← the whole tool (~150 lines) ├── CHANGELOG.md ← Keep a Changelog format, newest first @@ -43,16 +42,16 @@ Invoke-ps2exe -inputFile src/netswitch.ps1 -outputFile netswitch.exe ` 4. Tag: `git tag vX.Y.Z`. 5. Push: `git push && git push --tags`. -GitHub Actions picks up the tag, builds the exe via ps2exe, writes the SHA-256, and creates the GitHub Release with the zip attached. +Gitea Actions picks up the tag, builds the exe, writes the SHA-256, and creates the Gitea Release with the zip attached. ## Where features go The whole tool is a single PowerShell file with these sections (in order): -1. `$NetswitchVersion` / `$GithubRepo` — top of file. +1. `$NetswitchVersion` / `$Repo` — top of file. 2. **Self-elevate** block — UAC if non-admin. 3. **Banner** — Write-Host title. -4. **`Test-NetswitchUpdate`** — GitHub /releases/latest poll. +4. **`Test-NetswitchUpdate`** — Gitea /releases/latest poll. 5. **Adapter filter + picker** — `$skipDescriptionPattern`, `$skipMediaTypes`, `Get-NetAdapter | Where-Object {...}`. 6. **Mode prompt** — Static / DHCP. 7. **Static branch** — `netsh interface ipv4 set address ... static ...`. diff --git a/README.md b/README.md index 2c352e4..7cae545 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # netswitch -[![Latest release](https://img.shields.io/github/v/release/Engelgardt23/netswitch)](https://github.com/Engelgardt23/netswitch/releases/latest) +[![Latest release](https://img.shields.io/gitea/v/release/engel/netswitch?gitea_url=https%3A%2F%2Fgit.engelgardt23.ru&label=release)](https://git.engelgardt23.ru/engel/netswitch/releases/latest) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) 🇺🇸 English | [🇷🇺 Русский](README.ru.md) @@ -9,13 +9,11 @@ A tiny portable tool to flip a Windows network adapter between a **static IP** a Built for the recurring engineer chore of "give my laptop NIC 10.10.10.1 so I can talk to a server's BMC" and "now put it back on DHCP so I can have internet again." -> **Made by engelgardt.** - --- ## Download -Grab the latest release: [**releases page**](https://github.com/Engelgardt23/netswitch/releases/latest). +Grab the latest release: [**releases page**](https://git.engelgardt23.ru/engel/netswitch/releases/latest). The asset is `netswitch-portable-vX.Y.Z.zip` (~30 KB). ## Run @@ -34,7 +32,7 @@ Only real, wired physical adapters appear in the picker. Wireless, VPN, virtual, ## Update check -On every launch the tool calls GitHub's `/releases/latest` (3-second timeout). If a newer version is available, it prints a yellow notice and offers to open the download page in your browser. If you're offline, it stays silent. +On every launch the tool calls the Gitea instance's `/releases/latest` (3-second timeout). If a newer version is available, it prints a yellow notice and offers to open the download page in your browser. If you're offline, it stays silent. ## Build from source diff --git a/README.ru.md b/README.ru.md index f3ed398..1cf0abf 100644 --- a/README.ru.md +++ b/README.ru.md @@ -1,6 +1,6 @@ # netswitch -[![Последний релиз](https://img.shields.io/github/v/release/Engelgardt23/netswitch)](https://github.com/Engelgardt23/netswitch/releases/latest) +[![Последний релиз](https://img.shields.io/gitea/v/release/engel/netswitch?gitea_url=https%3A%2F%2Fgit.engelgardt23.ru&label=release)](https://git.engelgardt23.ru/engel/netswitch/releases/latest) [![Лицензия: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [🇺🇸 English](README.md) | 🇷🇺 Русский @@ -9,13 +9,11 @@ Решает регулярную задачу инженера: «дай моему ноуту 10.10.10.1, чтобы я мог достучаться до BMC сервера», а потом «верни обратно на DHCP, чтобы был интернет». -> **Автор: engelgardt.** - --- ## Скачать -Последний релиз: [**страница релизов**](https://github.com/Engelgardt23/netswitch/releases/latest). +Последний релиз: [**страница релизов**](https://git.engelgardt23.ru/engel/netswitch/releases/latest). Архив `netswitch-portable-vX.Y.Z.zip` (~30 КБ). ## Запуск @@ -35,7 +33,7 @@ ## Проверка обновлений -При каждом запуске тулза стучится в GitHub `/releases/latest` (таймаут 3 секунды). Если есть свежая версия — справа в шапке появится тусклая надпись `доступно обновление (vX.Y.Z)`. Если интернета нет — молчит. +При каждом запуске тулза стучится в Gitea `/releases/latest` (таймаут 3 секунды). Если есть свежая версия — справа в шапке появится тусклая надпись `доступно обновление (vX.Y.Z)`. Если интернета нет — молчит. ## Конфиг diff --git a/SECURITY.md b/SECURITY.md index 159bcbb..a2be919 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,16 +6,14 @@ vulnerability reports are very welcome. ## Supported versions -Only the latest tagged release on GitHub is supported. Older versions will not +Only the latest tagged release is supported. Older versions will not get fixes; please upgrade first. ## How to report a vulnerability **Please do not open a public issue** for security-sensitive findings. -Use GitHub's private security advisories: go to the -[Security tab](../../security/advisories/new) of this repo and click -"Report a vulnerability". GitHub will route it privately. +Report privately by email to the maintainer at engelgardt2024@gmail.com. Please include: - The version you tested (the startup banner is enough). diff --git a/pyproject.toml b/pyproject.toml index 81c41ce..63c3532 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,8 +13,8 @@ dependencies = ["rich>=13"] dynamic = ["version"] [project.urls] -Homepage = "https://github.com/Engelgardt23/netswitch" -Issues = "https://github.com/Engelgardt23/netswitch/issues" +Homepage = "https://git.engelgardt23.ru/engel/netswitch" +Issues = "https://git.engelgardt23.ru/engel/netswitch/issues" [project.scripts] netswitch = "netswitch.app:main" diff --git a/src/netswitch/__init__.py b/src/netswitch/__init__.py index 9d3a336..60d85dd 100644 --- a/src/netswitch/__init__.py +++ b/src/netswitch/__init__.py @@ -1,10 +1,9 @@ """ netswitch - portable Windows NIC IP / DHCP toggle. -made by engelgardt The single source of truth for the project version. Bump this before tagging a release; CI reads the tag, the code reads this constant. """ __version__ = "1.2.1" -GITHUB_REPO = "engel/netswitch" # на Forgejo (git.engelgardt23.ru) +REPO = "engel/netswitch" # self-hosted Gitea (git.engelgardt23.ru) diff --git a/src/netswitch/app.py b/src/netswitch/app.py index 41b5d20..5ea1c51 100644 --- a/src/netswitch/app.py +++ b/src/netswitch/app.py @@ -10,7 +10,7 @@ from rich.console import Console from rich.prompt import Prompt from rich.table import Table -from . import __version__, GITHUB_REPO +from . import __version__, REPO from .platform_win import enable_vt, require_admin from .config import load_config from .i18n import set_language, t @@ -69,7 +69,7 @@ def main() -> None: title = f"[bold cyan]netswitch v{__version__}[/] {t('tagline')}" latest = check_for_update() if latest: - release_url = f"https://git.engelgardt23.ru/{GITHUB_REPO}/releases/latest" + release_url = f"https://git.engelgardt23.ru/{REPO}/releases/latest" notice = t("update_available", tag=latest) header = Table.grid(expand=True) header.add_column(justify="left", ratio=1) diff --git a/src/netswitch/update_check.py b/src/netswitch/update_check.py index f305567..dae97f4 100644 --- a/src/netswitch/update_check.py +++ b/src/netswitch/update_check.py @@ -5,7 +5,7 @@ from __future__ import annotations import json import urllib.request -from . import __version__, GITHUB_REPO +from . import __version__, REPO def _parse_version(s: str) -> tuple[int, int, int]: @@ -21,7 +21,7 @@ def _parse_version(s: str) -> tuple[int, int, int]: def check_for_update() -> str | None: try: - url = f"https://git.engelgardt23.ru/api/v1/repos/{GITHUB_REPO}/releases/latest" + url = f"https://git.engelgardt23.ru/api/v1/repos/{REPO}/releases/latest" req = urllib.request.Request(url, headers={ "User-Agent": f"netswitch/{__version__}", })