-
Notifications
You must be signed in to change notification settings - Fork 1
170 lines (149 loc) · 6.16 KB
/
Copy pathrelease.yml
File metadata and controls
170 lines (149 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: release
on:
workflow_run:
workflows: ["build"]
types:
- completed
branches:
- main
jobs:
release:
runs-on:
group: ToakanLab
labels: [self-hosted, Windows]
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: RW-TradingControl-dll
path: ./artifacts
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Update 1.6 Assemblies
run: |
# List what's in the artifacts folder for debugging
Write-Host "Contents of artifacts folder:"
Get-ChildItem ./artifacts
# Ensure the directories exist
New-Item -ItemType Directory -Force -Path "1.6\Assemblies"
# Copy the DLL to both locations (try both possible names)
if (Test-Path "./artifacts/TradingControl.dll") {
Copy-Item "./artifacts/TradingControl.dll" "1.6\Assemblies\" -Force
Write-Host "Copied TradingControl.dll to 1.6\Assemblies"
} elseif (Test-Path "./artifacts/RW-TradingControl.dll") {
Copy-Item "./artifacts/RW-TradingControl.dll" "1.6\Assemblies\TradingControl.dll" -Force
Write-Host "Copied RW-TradingControl.dll to 1.6\Assemblies as TradingControl.dll"
} else {
Write-Host "ERROR: Could not find DLL file in artifacts"
Get-ChildItem ./artifacts -Recurse
}
shell: powershell
- name: Create Release Zip
run: |
# Create a clean temporary directory for the release
$releaseDir = "release-temp"
if (Test-Path $releaseDir) {
Remove-Item -Recurse -Force $releaseDir
}
New-Item -ItemType Directory -Force -Path $releaseDir
# Copy everything except excluded items
$excludeItems = @("Source", ".git", ".github", ".gitignore", "README.md", "release-temp", "artifacts", "TradingControl-Release.zip", "1.0", "1.2", "1.3", "1.4", "1.5", "default")
Get-ChildItem -Force | Where-Object {
$_.Name -notin $excludeItems
} | ForEach-Object {
Write-Host "Copying: $($_.Name)"
Copy-Item $_.FullName -Destination "$releaseDir\$($_.Name)" -Recurse -Force
}
# Create zip from the clean directory
Compress-Archive -Path "$releaseDir\*" -DestinationPath TradingControl-Release.zip -Force
# Clean up temp directory
Remove-Item -Recurse -Force $releaseDir
shell: powershell
- name: Get commit messages since last release
id: get_commits
run: |
# Get the latest release tag
$ErrorActionPreference = "SilentlyContinue"
$latestTag = git describe --tags --abbrev=0 2>$null
$ErrorActionPreference = "Stop"
if ($LASTEXITCODE -ne 0 -or -not $latestTag) {
Write-Host "No previous release found. Getting all commits."
# If no previous release, get all commits
$commits = git log --pretty=format:"- %s (%h)" --no-merges
} else {
Write-Host "Previous release found: $latestTag. Getting commits since then."
# Get commits since the last release
$commits = git log "$latestTag..HEAD" --pretty=format:"- %s (%h)" --no-merges
}
if (-not $commits) {
$commits = "- No new commits since last release"
}
# Escape for GitHub Actions output
$commits = $commits -join "`n"
echo "COMMIT_MESSAGES<<EOF" >> $env:GITHUB_ENV
echo $commits >> $env:GITHUB_ENV
echo "EOF" >> $env:GITHUB_ENV
shell: powershell
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Release v${{ github.run_number }}
body: |
Automated release from commit ${{ github.sha }}
## Changes in this release:
${{ env.COMMIT_MESSAGES }}
---
Built from latest main branch with compiled RW-TradingControl.dll
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./TradingControl-Release.zip
asset_name: TradingControl-Release.zip
asset_content_type: application/zip
- name: Cleanup temporary files
run: |
# Remove temporary directories and files
if (Test-Path "artifacts") {
Remove-Item -Recurse -Force "artifacts"
Write-Host "Removed artifacts directory"
}
if (Test-Path "Assemblies") {
Remove-Item -Recurse -Force "Assemblies"
Write-Host "Removed Assemblies directory"
}
if (Test-Path "TradingControl-Release.zip") {
Remove-Item -Force "TradingControl-Release.zip"
Write-Host "Removed release zip file"
}
Write-Host "Cleanup completed"
shell: powershell
- name: Cleanup workspace
if: always()
run: |
# Clean up the workspace contents (but not the workspace directory itself)
Get-ChildItem -Force | ForEach-Object {
try {
Remove-Item -Path $_.FullName -Recurse -Force
Write-Host "Removed: $($_.Name)"
} catch {
Write-Host "Could not remove: $($_.Name) - $($_.Exception.Message)"
}
}
Write-Host "Workspace cleanup completed"
shell: powershell