Skip to content

Commit c49096c

Browse files
committed
Github Action: Build and Release automatically
1 parent 13f00b9 commit c49096c

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch: # Allow manual triggering
7+
8+
jobs:
9+
build-and-release:
10+
runs-on: windows-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0 # Fetch full history for version bumping
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v4
20+
with:
21+
go-version: '1.21'
22+
23+
- name: Get current version
24+
id: get_version
25+
run: |
26+
$currentVersion = Get-Content VERSION -Raw
27+
$currentVersion = $currentVersion.Trim()
28+
Write-Host "Current version: $currentVersion"
29+
echo "current_version=$currentVersion" >> $env:GITHUB_OUTPUT
30+
31+
# Parse version components
32+
$versionParts = $currentVersion -split '\.'
33+
$major = [int]$versionParts[0]
34+
$minor = [int]$versionParts[1]
35+
$patch = [int]$versionParts[2]
36+
37+
# Increment patch version
38+
$patch++
39+
$newVersion = "$major.$minor.$patch"
40+
Write-Host "New version: $newVersion"
41+
echo "new_version=$newVersion" >> $env:GITHUB_OUTPUT
42+
43+
- name: Update version file
44+
run: |
45+
echo "${{ steps.get_version.outputs.new_version }}" > VERSION
46+
Write-Host "Updated VERSION file to: ${{ steps.get_version.outputs.new_version }}"
47+
48+
- name: Create logs directory
49+
run: |
50+
if (-not (Test-Path "logs")) {
51+
New-Item -ItemType Directory -Path "logs"
52+
}
53+
54+
- name: Download dependencies
55+
run: |
56+
go mod tidy
57+
58+
- name: Create dist directory
59+
run: |
60+
if (-not (Test-Path "dist")) {
61+
New-Item -ItemType Directory -Path "dist"
62+
}
63+
64+
- name: Build executable
65+
run: |
66+
Write-Host "Building UE-Git-Plugin-Manager.exe..."
67+
go build -o dist/UE-Git-Plugin-Manager.exe .
68+
if ($LASTEXITCODE -ne 0) {
69+
Write-Error "Build failed!"
70+
exit 1
71+
}
72+
Write-Host "Build successful!"
73+
74+
- name: Verify executable
75+
run: |
76+
if (Test-Path "dist/UE-Git-Plugin-Manager.exe") {
77+
$fileSize = (Get-Item "dist/UE-Git-Plugin-Manager.exe").Length
78+
Write-Host "Executable created successfully. Size: $fileSize bytes"
79+
} else {
80+
Write-Error "Executable not found!"
81+
exit 1
82+
}
83+
84+
- name: Commit version update
85+
run: |
86+
git config --local user.email "action@github.com"
87+
git config --local user.name "GitHub Action"
88+
git add VERSION
89+
git commit -m "Bump version to ${{ steps.get_version.outputs.new_version }} [skip ci]" || exit 0
90+
git push origin main || exit 0
91+
92+
- name: Create Release
93+
uses: actions/create-release@v1
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
with:
97+
tag_name: v${{ steps.get_version.outputs.new_version }}
98+
release_name: Release v${{ steps.get_version.outputs.new_version }}
99+
body: |
100+
## Changes in v${{ steps.get_version.outputs.new_version }}
101+
102+
This release includes the latest changes from the main branch.
103+
104+
### Download
105+
Download the `UE-Git-Plugin-Manager.exe` file below and run it to use the latest version.
106+
107+
### Installation
108+
1. Download `UE-Git-Plugin-Manager.exe`
109+
2. Run the executable
110+
3. Follow the setup wizard
111+
draft: false
112+
prerelease: false
113+
114+
- name: Upload Release Asset
115+
uses: actions/upload-release-asset@v1
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
with:
119+
upload_url: ${{ steps.create_release.outputs.upload_url }}
120+
asset_path: ./dist/UE-Git-Plugin-Manager.exe
121+
asset_name: UE-Git-Plugin-Manager.exe
122+
asset_content_type: application/octet-stream

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.1

0 commit comments

Comments
 (0)