Skip to content

Refactor build scripts and version management; update to version 1.0.… #8

Refactor build scripts and version management; update to version 1.0.…

Refactor build scripts and version management; update to version 1.0.… #8

name: Build and Release
on:
push:
branches: [ main ]
workflow_dispatch: # Allow manual triggering
jobs:
build-and-release:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for version bumping
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Get version from VERSION file
id: get_version
run: |
$version = Get-Content VERSION -Raw
$version = $version.Trim()
Write-Host "Building release for version: $version"
echo "version=$version" >> $env:GITHUB_OUTPUT
- name: Create logs directory
run: |
if (-not (Test-Path "logs")) {
New-Item -ItemType Directory -Path "logs"
}
- name: Download dependencies
run: |
go mod tidy
- name: Create dist directory
run: |
if (-not (Test-Path "dist")) {
New-Item -ItemType Directory -Path "dist"
}
- name: Build executable
id: build_executable
run: |
$version = ${{ steps.get_version.outputs.version }}
$exeName = "UE-Git-Plugin-Manager-v$version.exe"
$exePath = "dist/$exeName"
Write-Host "Building $exeName..."
go build -o $exePath .
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed!"
exit 1
}
Write-Host "Build successful!"
echo "exe_name=$exeName" >> $env:GITHUB_OUTPUT
echo "exe_path=$exePath" >> $env:GITHUB_OUTPUT
- name: Verify executable
run: |
$exeName = "${{ steps.build_executable.outputs.exe_name }}"
$exePath = "${{ steps.build_executable.outputs.exe_path }}"
if (Test-Path $exePath) {
$fileSize = (Get-Item $exePath).Length
Write-Host "Executable created successfully: $exeName"
Write-Host "Size: $fileSize bytes"
} else {
Write-Error "Executable not found: $exePath"
exit 1
}
- name: Log version info
run: |
Write-Host "Building release for version: ${{ steps.get_version.outputs.version }}"
Write-Host "Version is controlled by the VERSION file in the repository"
- name: Create Release
run: |
$version = "${{ steps.get_version.outputs.version }}"
$exeName = "${{ steps.build_executable.outputs.exe_name }}"
$exePath = "${{ steps.build_executable.outputs.exe_path }}"
$notes = @"
## Changes in v$version
This release includes the latest changes from the main branch.

Check failure on line 89 in .github/workflows/build-and-release.yml

View workflow run for this annotation

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

Invalid workflow file

You have an error in your yaml syntax on line 89
### Download
Download the ``$exeName`` file below and run it to use the latest version.
### Installation
1. Download ``$exeName``
2. Run the executable
3. Follow the setup wizard
"@
gh release create "v$version" --title "Release v$version" --notes $notes $exePath
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}