84 lines
2.6 KiB
YAML
84 lines
2.6 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Build release binary
|
|
shell: powershell
|
|
run: cargo build --release
|
|
|
|
- name: Build installer
|
|
shell: powershell
|
|
run: |
|
|
cargo wix --nocapture
|
|
|
|
- name: Create Gitea Release
|
|
id: create_release
|
|
shell: powershell
|
|
run: |
|
|
$tag = "${{ github.ref_name }}"
|
|
$body = @{
|
|
tag_name = $tag
|
|
name = "Tickr $tag"
|
|
body = "Automated release $tag"
|
|
draft = $false
|
|
prerelease = $false
|
|
} | ConvertTo-Json
|
|
|
|
$response = Invoke-RestMethod `
|
|
-Uri "https://gitea.whitlocktech.com/api/v1/repos/whitlocktech/tickr/releases" `
|
|
-Method Post `
|
|
-Headers @{
|
|
Authorization = "token ${{ secrets.RELEASE_TOKEN }}"
|
|
"Content-Type" = "application/json"
|
|
} `
|
|
-Body $body
|
|
|
|
$releaseId = $response.id
|
|
Write-Host "Created release ID: $releaseId"
|
|
Add-Content -Path $env:GITHUB_OUTPUT -Value "release_id=$releaseId"
|
|
|
|
- name: Upload binary asset
|
|
shell: powershell
|
|
run: |
|
|
$releaseId = "${{ steps.create_release.outputs.release_id }}"
|
|
$filePath = (Resolve-Path "target\release\tickr.exe").Path
|
|
|
|
Write-Host "Working dir: $(Get-Location)"
|
|
Write-Host "Release ID: $releaseId"
|
|
Write-Host "File: $filePath"
|
|
|
|
if (!(Test-Path $filePath)) {
|
|
Write-Error "File not found: $filePath"
|
|
exit 1
|
|
}
|
|
|
|
$uri = "https://gitea.whitlocktech.com/api/v1/repos/whitlocktech/tickr/releases/$releaseId/assets?name=tickr.exe"
|
|
|
|
& curl.exe -X POST -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" -F "attachment=@$filePath" "$uri"
|
|
|
|
- name: Upload installer
|
|
shell: powershell
|
|
run: |
|
|
$releaseId = "${{ steps.create_release.outputs.release_id }}"
|
|
$msiPath = (Get-ChildItem -Path "target\wix\*.msi" | Select-Object -First 1).FullName
|
|
|
|
Write-Host "MSI Path: $msiPath"
|
|
|
|
if (!(Test-Path $msiPath)) {
|
|
Write-Error "MSI not found"
|
|
exit 1
|
|
}
|
|
|
|
$uri = "https://gitea.whitlocktech.com/api/v1/repos/whitlocktech/tickr/releases/$releaseId/assets?name=tickr-setup.msi"
|
|
|
|
& curl.exe -X POST -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" -F "attachment=@$msiPath" "$uri" |