Skip to content

Commit 85e3adc

Browse files
committed
fix: repair v3 release workflows
1 parent 6deb96e commit 85e3adc

3 files changed

Lines changed: 17 additions & 50 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,25 @@ jobs:
3232
run: |
3333
$ErrorActionPreference = 'Stop'
3434
$archive = Join-Path $env:RUNNER_TEMP 'manga-translator-ui-portable.7z'
35-
$portableDir = Join-Path $env:GITHUB_WORKSPACE 'portable'
35+
$extractDir = Join-Path $env:GITHUB_WORKSPACE 'portable'
3636
gh release download portable --repo hgmzhn/manga-translator-ui --pattern manga-translator-ui-portable.7z --output $archive --clobber
3737
if ($LASTEXITCODE -ne 0) { throw 'Failed to download the portable reference package.' }
38-
Remove-Item $portableDir -Recurse -Force -ErrorAction SilentlyContinue
39-
7z x $archive -o$portableDir -y
38+
Remove-Item $extractDir -Recurse -Force -ErrorAction SilentlyContinue
39+
7z x $archive -o$extractDir -y
4040
if ($LASTEXITCODE -ne 0) { throw 'Failed to extract the portable reference package.' }
4141
Remove-Item $archive -Force
42-
$nested = Join-Path $portableDir 'manga-translator-ui-portable'
43-
if (Test-Path (Join-Path $nested 'Win-Start.bat')) { $portableDir = $nested }
42+
$pythonCandidates = @(
43+
Get-ChildItem -LiteralPath $extractDir -Filter python.exe -File -Recurse |
44+
Where-Object { $_.FullName -match '[\\/]packaging[\\/]python[\\/]python\.exe$' }
45+
)
46+
if ($pythonCandidates.Count -ne 1) {
47+
throw "Expected exactly one portable Python, found $($pythonCandidates.Count)."
48+
}
49+
$portableDir = $pythonCandidates[0].Directory.Parent.Parent.FullName
50+
if (-not (Test-Path (Join-Path $portableDir 'Win-Start.bat'))) {
51+
throw "Portable root was not found next to $($pythonCandidates[0].FullName)."
52+
}
53+
4454
$excluded = @('.git', '.github', '.venv', '.venv_cpu', '.venv_gpu', 'build', 'dist', 'models', 'models_backup', 'result', 'logs', 'scripts', 'test', 'reference-code', 'PortableGit', 'uploads', 'upload-cache', 'originals', 'manga_translator_work', 'memory_profiles', '.idea', '.vscode')
4555
Get-ChildItem -LiteralPath $env:GITHUB_WORKSPACE -Force |
4656
Where-Object { $_.Name -notin $excluded -and $_.Name -ne 'portable' } |

.github/workflows/docker-build-push.yml

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -87,51 +87,6 @@ jobs:
8787
flavor: |
8888
latest=false
8989
90-
- name: Delete existing version tags before push
91-
if: github.event_name != 'pull_request' && github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
92-
env:
93-
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
94-
GH_TOKEN: ${{ secrets.GH_PAT }}
95-
PACKAGE_OWNER: ${{ github.repository_owner }}
96-
IMAGE_NAME: ${{ env.IMAGE_NAME }}
97-
run: |
98-
set -Eeuo pipefail
99-
VERSION="${GITHUB_REF_NAME#v}"
100-
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-].*)?$ ]]; then
101-
echo "Not a semantic version tag: $GITHUB_REF_NAME; skip deletion."
102-
exit 0
103-
fi
104-
TARGET_TAG="${VERSION}-${{ matrix.build_type }}"
105-
echo "Removing existing Docker tag: $TARGET_TAG"
106-
107-
HUB_TOKEN=$(curl --fail --silent --show-error \
108-
--user "${DOCKERHUB_USERNAME}:${DOCKERHUB_TOKEN}" \
109-
"https://auth.docker.io/token?service=registry.docker.io&scope=repository:${DOCKERHUB_USERNAME}/${IMAGE_NAME}:pull,push" \
110-
| jq -r '.token')
111-
if [[ -z "$HUB_TOKEN" || "$HUB_TOKEN" == "null" ]]; then
112-
echo 'Docker Hub authentication token was not returned.' >&2
113-
exit 1
114-
fi
115-
HUB_STATUS=$(curl --silent --show-error -o /dev/null -w '%{http_code}' \
116-
--request DELETE \
117-
--header "Authorization: Bearer ${HUB_TOKEN}" \
118-
"https://hub.docker.com/v2/repositories/${DOCKERHUB_USERNAME}/${IMAGE_NAME}/tags/${TARGET_TAG}/")
119-
if [[ "$HUB_STATUS" != '204' && "$HUB_STATUS" != '404' ]]; then
120-
echo "Docker Hub tag deletion failed with HTTP $HUB_STATUS" >&2
121-
exit 1
122-
fi
123-
124-
VERSION_IDS=$(TARGET_TAG="$TARGET_TAG" gh api --paginate \
125-
"/users/${PACKAGE_OWNER}/packages/container/${IMAGE_NAME}/versions?per_page=100" \
126-
--jq '.[] | select((.metadata.container.tags // []) | index(env.TARGET_TAG)) | .id')
127-
while IFS= read -r VERSION_ID; do
128-
[[ -z "$VERSION_ID" ]] && continue
129-
echo "Removing GHCR package version $VERSION_ID for $TARGET_TAG"
130-
gh api --method DELETE \
131-
"/users/${PACKAGE_OWNER}/packages/container/${IMAGE_NAME}/versions/${VERSION_ID}"
132-
done <<< "$VERSION_IDS"
133-
134-
echo "Existing Docker tags removed; the next step will push the new image."
13590
- name: Build and push Docker image
13691
id: build
13792
uses: docker/build-push-action@v5

test/test_update_fetch_failure.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def test_check_version_info_fetch_failure_reports_warning(tmp_path, monkeypatch,
3232
def fake_run(cmd, *args, **kwargs):
3333
if cmd[1:3] == ["fetch", "origin"]:
3434
return SimpleNamespace(returncode=1, stdout="", stderr="network error")
35+
if cmd[1:3] == ["rev-parse", "HEAD"]:
36+
return SimpleNamespace(returncode=0, stdout="abc123\n", stderr="")
3537
raise AssertionError(f"unexpected subprocess call: {cmd}")
3638

3739
monkeypatch.setattr(launch.subprocess, "run", fake_run)

0 commit comments

Comments
 (0)