-
-
Notifications
You must be signed in to change notification settings - Fork 181
132 lines (114 loc) · 4.14 KB
/
windows-dev.yaml
File metadata and controls
132 lines (114 loc) · 4.14 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
name: Build Dev Release
on:
workflow_dispatch:
pull_request:
types: [closed]
branches:
- main
- feature/*
- dev
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Create virtual environment
run: |
python -m venv venv
shell: pwsh
- name: Get App Info
id: get_info
run: |
.\venv\Scripts\Activate
$currentDateTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss UTC"
echo "BUILD_DATETIME=$currentDateTime" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$commitHash = git rev-parse --short HEAD
echo "COMMIT_HASH=$commitHash" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Update Release Channel for Dev Build
run: |
.\venv\Scripts\Activate
$settingsPath = "src/settings.py"
$content = Get-Content $settingsPath -Raw
$content = $content -replace 'RELEASE_CHANNEL = "stable"', 'RELEASE_CHANNEL = "dev-${{ env.COMMIT_HASH }}"'
Set-Content -Path $settingsPath -Value $content -NoNewline
echo "Updated RELEASE_CHANNEL to dev-${{ env.COMMIT_HASH }}"
shell: pwsh
- name: Activate virtual environment and install dependencies
run: |
.\venv\Scripts\Activate
python -m pip install --upgrade pip
pip install --force --no-cache -r requirements.txt
pip install --force --no-cache --upgrade cx_Freeze==7.2.10
shell: pwsh
- name: Build MSI
run: |
.\venv\Scripts\Activate
cd src
python build.py bdist_msi
shell: pwsh
- name: Rename Artifacts File
run: |
$sourceMsi = (Get-ChildItem -Path src/dist/out/*.msi).FullName
$targetMsi = "src/dist/out/yasb-dev-win64.msi"
Copy-Item -Path $sourceMsi -Destination $targetMsi -Force
Remove-Item -Path $sourceMsi
echo "FILENAME=yasb-dev-win64.msi" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Generate Changelog
id: generate_changelog
if: github.event_name == 'workflow_dispatch'
run: |
# Find the latest version tag
$latestVersionTag = $(try { git tag --sort=-version:refname | Where-Object { $_ -match "^v\d+\.\d+\.\d+" } | Select-Object -First 1 } catch { $null })
if ($latestVersionTag) {
$commits = $(git log "$latestVersionTag..HEAD" --pretty=format:"* %s (%h)" --no-merges)
} else {
$commits = $(git log -n 20 --pretty=format:"* %s (%h)" --no-merges)
}
if ($commits) {
$changelog += $commits -join "`n"
} else {
$changelog += "* No significant changes detected since $latestVersionTag"
}
# Save changelog to file for the release body
$changelog | Out-File -FilePath "CHANGELOG.md" -Encoding utf8
shell: pwsh
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: yasb-dev-${{ env.COMMIT_HASH }}
path: |
src/dist/out/*.msi
retention-days: 10
- name: Delete existing dev release
if: github.event_name == 'workflow_dispatch'
run: |
# Delete existing release if it exists (ignore errors if it doesn't)
gh release delete dev --yes || true
# Delete the tag locally and remotely
git tag -d dev || true
git push origin :refs/tags/dev || true
env:
GH_TOKEN: ${{ github.token }}
shell: pwsh
- name: Create GitHub Release
if: github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v1
with:
name: YASB Pre-release (${{ env.COMMIT_HASH }})
tag_name: dev
prerelease: true
files: |
src/dist/out/*.msi
body_path: CHANGELOG.md