Files
lingma-proxy-compose/.github/workflows/release.yml
2026-03-30 17:13:35 +08:00

82 lines
2.4 KiB
YAML

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag, for example v0.1.0"
required: true
permissions:
contents: write
jobs:
test:
name: Test
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run tests
run: go test ./...
build-release:
name: Build And Publish Release
runs-on: windows-latest
needs: test
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
EXE_NAME: lingma-ipc-proxy_${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}_windows_amd64.exe
ARCHIVE_NAME: lingma-ipc-proxy_${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}_windows_amd64.zip
CHECKSUM_NAME: lingma-ipc-proxy_${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}_sha256.txt
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build binary
shell: pwsh
run: .\scripts\build.ps1 -Clean
- name: Prepare release assets
shell: pwsh
run: |
Copy-Item .\dist\lingma-ipc-proxy.exe .\$env:EXE_NAME -Force
$exePath = Join-Path $PWD $env:EXE_NAME
$archivePath = Join-Path $PWD $env:ARCHIVE_NAME
$checksumPath = Join-Path $PWD $env:CHECKSUM_NAME
Compress-Archive -Path $exePath -DestinationPath $archivePath -Force
$exeHash = (Get-FileHash -Algorithm SHA256 $exePath).Hash.ToLowerInvariant()
$zipHash = (Get-FileHash -Algorithm SHA256 $archivePath).Hash.ToLowerInvariant()
@(
"$exeHash $($env:EXE_NAME)"
"$zipHash $($env:ARCHIVE_NAME)"
) | Set-Content $checksumPath
- name: Create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
generate_release_notes: true
files: |
${{ env.EXE_NAME }}
${{ env.ARCHIVE_NAME }}
${{ env.CHECKSUM_NAME }}