@@ -14,12 +14,12 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Ensure toolchain and install cross
|
- name: Ensure toolchain and cross
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
rustc -V
|
rustc -V
|
||||||
cargo -V
|
cargo -V
|
||||||
cargo install cross --git https://github.com/cross-rs/cross
|
if (-not (Get-Command cross -ErrorAction SilentlyContinue)) { cargo install cross --git https://github.com/cross-rs/cross }
|
||||||
|
|
||||||
- name: Cache cargo
|
- name: Cache cargo
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
@@ -41,7 +41,7 @@ jobs:
|
|||||||
./scripts/package_rootfs.ps1 -Version "${{ github.ref_name }}" -Target armv7-unknown-linux-musleabihf
|
./scripts/package_rootfs.ps1 -Version "${{ github.ref_name }}" -Target armv7-unknown-linux-musleabihf
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: wakey-rootfs
|
name: wakey-rootfs
|
||||||
path: dist/wakey-rootfs-*armv7-unknown-linux-musleabihf.tgz
|
path: dist/wakey-rootfs-*armv7-unknown-linux-musleabihf.tgz
|
||||||
@@ -52,19 +52,4 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
if (-not $env:GITEA_TOKEN) { throw "Missing secrets.GITEA_TOKEN" }
|
./scripts/ci_gitea_release.ps1 -Tag "$env:GITHUB_REF_NAME" -AssetPattern "dist/wakey-rootfs-*armv7-unknown-linux-musleabihf.tgz"
|
||||||
$repoParts = $env:GITHUB_REPOSITORY -split '/'
|
|
||||||
$owner = $repoParts[0]
|
|
||||||
$name = $repoParts[1]
|
|
||||||
$api = $env:GITHUB_API_URL
|
|
||||||
$tag = $env:GITHUB_REF_NAME
|
|
||||||
$asset = Get-ChildItem dist\wakey-rootfs-*armv7-unknown-linux-musleabihf.tgz | Select-Object -First 1
|
|
||||||
if (-not $asset) { throw "No rootfs artifact found in dist" }
|
|
||||||
$headers = @{ Authorization = "token $env:GITEA_TOKEN" }
|
|
||||||
$body = @{ tag_name=$tag; name=$tag; draft=$false; prerelease=$false } | ConvertTo-Json
|
|
||||||
$release = Invoke-RestMethod -Headers $headers -Uri "$api/repos/$owner/$name/releases" -Method Post -Body $body -ContentType 'application/json'
|
|
||||||
$rid = $release.id
|
|
||||||
if (-not $rid) { throw "Failed to create release: $($release | ConvertTo-Json -Depth 5)" }
|
|
||||||
$uploadUri = "$api/repos/$owner/$name/releases/$rid/assets?name=$($asset.Name)"
|
|
||||||
Invoke-WebRequest -Headers $headers -Uri $uploadUri -Method Post -InFile $asset.FullName -ContentType 'application/gzip' | Out-Null
|
|
||||||
Write-Host "Release published: tag $tag with asset $($asset.Name)"
|
|
||||||
|
|||||||
+38
-7
@@ -1,8 +1,16 @@
|
|||||||
# Starts the Gitea act_runner if not already running.
|
# Starts the Gitea act_runner if not already running.
|
||||||
# Usage: ./scripts/act_runner.ps1 -Config "C:/Users/Admin/Documents/gitea/.runner" -RunnerPath "C:/Users/Admin/Documents/gitea/act_runner.exe"
|
# Usage: ./scripts/act_runner.ps1 -Config "C:/Users/Admin/Documents/gitea/runner.yaml" -RunnerPath "C:/Users/Admin/Documents/gitea/act_runner.exe" -ServerUrl "https://git.ldlda.com/" -Token "<reg token>" -Labels "self-hosted,windows"
|
||||||
param(
|
param(
|
||||||
[string]$RunnerPath = "$HOME/Documents/gitea/act_runner.exe",
|
[string]$RunnerPath = "$HOME/Documents/gitea/act_runner.exe",
|
||||||
[string]$Config = "$HOME/Documents/gitea/.runner"
|
# Config is a FILE path (e.g., runner.yaml). Parent folder will be created if missing.
|
||||||
|
[string]$Config = "$HOME/Documents/gitea/config.yaml",
|
||||||
|
[string]$ServerUrl,
|
||||||
|
[string]$Token,
|
||||||
|
[string]$Labels = "windows:host,self-hosted",
|
||||||
|
# Opt-in to non-interactive configure; by default we print the command for you to run manually.
|
||||||
|
[switch]$ForceConfigure,
|
||||||
|
# When -Attach, run in the foreground to see logs (good for first-time troubleshooting)
|
||||||
|
[switch]$Attach
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
@@ -18,10 +26,33 @@ if ($running) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Ensure config exists
|
# Ensure config exists
|
||||||
if (-not (Test-Path $Config)) {
|
$configFile = $Config
|
||||||
Write-Host "Config not found. Initializing..."
|
$configDir = Split-Path -Parent $configFile
|
||||||
& $RunnerPath configure --no-interactive --config $Config
|
Set-Location $configDir
|
||||||
|
if (-not (Test-Path $configDir)) { New-Item -ItemType Directory -Force -Path $configDir | Out-Null }
|
||||||
|
|
||||||
|
if (-not (Test-Path $configFile)) {
|
||||||
|
if (-not $ServerUrl -or -not $Token) {
|
||||||
|
Write-Host "Config not found at $configFile. Provide -ServerUrl and -Token for non-interactive setup, or run register manually:"
|
||||||
|
Write-Host "`t$RunnerPath register --config $configFile"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
if ($ForceConfigure) {
|
||||||
|
Write-Host "Config not found. Initializing non-interactively (ForceConfigure)..."
|
||||||
|
& $RunnerPath register --no-interactive --config $configFile --instance $ServerUrl --token $Token --labels $Labels
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Config not found. Run this manually once (note labels embed host executor on Windows):"
|
||||||
|
Write-Host "`t$RunnerPath register --no-interactive --config `"$configFile`" --instance `"$ServerUrl`" --token `"$Token`" --labels `"$Labels`""
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Start-Process -FilePath $RunnerPath -ArgumentList @("daemon", "--config", $Config) -WindowStyle Hidden
|
if ($Attach) {
|
||||||
Write-Host "act_runner started."
|
Write-Host "Starting act_runner (attached)... Ctrl+C to stop"
|
||||||
|
& $RunnerPath daemon --config $configFile
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Start-Process -FilePath $RunnerPath -ArgumentList @("daemon", "--config", $configFile) -WindowStyle Hidden
|
||||||
|
Write-Host "act_runner started."
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)][string]$Tag,
|
||||||
|
[Parameter(Mandatory = $true)][string]$AssetPattern,
|
||||||
|
[string]$ServerUrl,
|
||||||
|
[string]$Token,
|
||||||
|
[string]$Owner,
|
||||||
|
[string]$Repo
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
# Resolve token
|
||||||
|
if (-not $Token) { $Token = $env:GITEA_TOKEN }
|
||||||
|
if (-not $Token) { throw 'Missing Gitea token. Set -Token or $env:GITEA_TOKEN' }
|
||||||
|
|
||||||
|
# Resolve repo owner/name
|
||||||
|
if (-not $Owner -or -not $Repo) {
|
||||||
|
if ($env:GITHUB_REPOSITORY) {
|
||||||
|
$parts = $env:GITHUB_REPOSITORY -split '/'
|
||||||
|
$Owner = $Owner ?: $parts[0]
|
||||||
|
$Repo = $Repo ?: $parts[1]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw 'Missing Owner/Repo and GITHUB_REPOSITORY not set'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Resolve API base
|
||||||
|
$api = $env:GITHUB_API_URL
|
||||||
|
if (-not $api -and $env:GITHUB_SERVER_URL) { $api = "$($env:GITHUB_SERVER_URL)/api/v1" }
|
||||||
|
if (-not $api -and $ServerUrl) { $api = "$ServerUrl/api/v1" }
|
||||||
|
if (-not $api) { throw 'Could not determine Gitea API URL. Provide -ServerUrl or set GITHUB_SERVER_URL/GITHUB_API_URL' }
|
||||||
|
|
||||||
|
# Find asset
|
||||||
|
$asset = Get-ChildItem -Path $AssetPattern -ErrorAction Stop | Select-Object -First 1
|
||||||
|
if (-not $asset) { throw "No asset matches pattern: $AssetPattern" }
|
||||||
|
|
||||||
|
$headers = @{ Authorization = "token $Token" }
|
||||||
|
$body = @{ tag_name = $Tag; name = $Tag; draft = $false; prerelease = $false } | ConvertTo-Json
|
||||||
|
|
||||||
|
Write-Host "Creating release $Tag for $Owner/$Repo"
|
||||||
|
try {
|
||||||
|
$release = Invoke-RestMethod -Headers $headers -Uri "$api/repos/$Owner/$Repo/releases" -Method Post -Body $body -ContentType 'application/json'
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
# If already exists, fetch by tag
|
||||||
|
Write-Host "Create failed; trying to fetch existing release for tag $Tag" -ForegroundColor Yellow
|
||||||
|
$release = Invoke-RestMethod -Headers $headers -Uri "$api/repos/$Owner/$Repo/releases/tags/$Tag" -Method Get
|
||||||
|
}
|
||||||
|
|
||||||
|
$rid = $release.id
|
||||||
|
if (-not $rid) { throw "Failed to resolve release id: $($release | ConvertTo-Json -Depth 5)" }
|
||||||
|
|
||||||
|
$uploadUri = "$api/repos/$Owner/$Repo/releases/$rid/assets?name=$($asset.Name)"
|
||||||
|
Write-Host "Uploading asset $($asset.Name)"
|
||||||
|
Invoke-WebRequest -Headers $headers -Uri $uploadUri -Method Post -InFile $asset.FullName -ContentType 'application/gzip' | Out-Null
|
||||||
|
Write-Host "Release published: tag $Tag with asset $($asset.Name)"
|
||||||
Reference in New Issue
Block a user