# moyun-ultimate publisher (ASCII only) # Creates the GitHub repo (if missing), pushes main, and prints the market PR steps. # Token is used in-memory only and is stripped from the remote URL afterwards. # # $env:GITHUB_TOKEN = 'ghp_xxx' # or pass -Token # .\publish.ps1 -Owner your-github-name # .\publish.ps1 -Owner your-name -DryRun [CmdletBinding()] param( [string]$Token = $env:GITHUB_TOKEN, [string]$Owner = '', [string]$Repo = 'moyun-ultimate', [string]$Description = 'Five-layer fused jailbreak core for DeepSeek Harness', [switch]$Private, [switch]$DryRun ) $ErrorActionPreference = 'Stop' $Here = Split-Path -Parent $MyInvocation.MyCommand.Path $Git = 'F:\Git\cmd\git.exe' if (-not (Test-Path $Git)) { $Git = 'git' } if (-not $Token) { throw 'No token. Set $env:GITHUB_TOKEN or pass -Token. Create one at https://github.com/settings/tokens/new (scope: repo).' } $H = @{ 'Authorization' = "Bearer $Token" 'Accept' = 'application/vnd.github+json' 'User-Agent' = 'moyun-ultimate-publisher' 'X-GitHub-Api-Version' = '2022-11-28' } # 1) who am I try { $me = Invoke-RestMethod 'https://api.github.com/user' -Headers $H -TimeoutSec 20 Write-Output "authenticated as: $($me.login)" if (-not $Owner) { $Owner = $me.login } } catch { throw "Token rejected by GitHub: $($_.Exception.Message)" } Write-Output "target repo : $Owner/$Repo" Write-Output "visibility : $(if ($Private) { 'private' } else { 'public' })" # 2) create repo if missing $exists = $false try { $null = Invoke-RestMethod "https://api.github.com/repos/$Owner/$Repo" -Headers $H -TimeoutSec 20 $exists = $true Write-Output "repo exists, will push into it" } catch { Write-Output "repo does not exist yet" } if (-not $exists) { if ($DryRun) { Write-Output "[dry] would create $Owner/$Repo" } else { $body = @{ name = $Repo description = $Description private = [bool]$Private has_issues = $true has_wiki = $false auto_init = $false } | ConvertTo-Json try { $null = Invoke-RestMethod "https://api.github.com/user/repos" -Method Post -Headers $H -Body $body -ContentType 'application/json' -TimeoutSec 30 Write-Output "created $Owner/$Repo" } catch { throw "create repo failed: $($_.Exception.Message)" } } } # 3) push (token in the URL for this one command only) Push-Location $Here try { $remoteUrl = "https://github.com/$Owner/$Repo.git" $existing = & $Git remote 2>$null if ($existing -contains 'origin') { & $Git remote remove origin | Out-Null } & $Git remote add origin $remoteUrl Write-Output "remote origin -> $remoteUrl" $pushUrl = "https://x-access-token:$Token@github.com/$Owner/$Repo.git" if ($DryRun) { Write-Output "[dry] would run: git push $pushUrl main" } else { & $Git push $pushUrl main 2>&1 | ForEach-Object { # never echo the token ($_ -replace [regex]::Escape($Token), '***') } if ($LASTEXITCODE -ne 0) { throw "git push failed (exit $LASTEXITCODE)" } Write-Output 'pushed main' } } finally { Pop-Location } # 4) next steps Write-Output '' Write-Output '==========================================================' Write-Output ' repo: https://github.com/' + $Owner + '/' + $Repo Write-Output '==========================================================' Write-Output '' Write-Output 'Market submission (awesome-dsh-plugin), two options:' Write-Output '' Write-Output ' A. PR (recommended)' Write-Output ' 1. fork https://github.com/awesome-dsh-plugin/awesome-dsh-plugin' Write-Output ' 2. add file: data/plugins/' + $Owner + '__' + $Repo + '.yml' Write-Output ' (template is in market/moyun-ultimate.yml -- replace GITHUB_OWNER)' Write-Output ' 3. optional icon: data/icons/' + $Owner + '__' + $Repo + '.png' Write-Output ' 4. open PR; describe what the plugin does and why it is layered' Write-Output '' Write-Output ' B. Release first (helps reviewers)' Write-Output (' tag v0.1.0 and attach moyun-ultimate-0.1.0.tgz') Write-Output '' Write-Output 'Verify the pushed file tree:' Write-Output (' https://github.com/' + $Owner + '/' + $Repo)