-
Notifications
You must be signed in to change notification settings - Fork 24
122 lines (108 loc) · 3.48 KB
/
windows.yaml
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
name: Windows
on:
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: windows-latest
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: Activate virtual environment and install dependencies
run: |
.\venv\Scripts\Activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install colorama
pip install --upgrade cx_Freeze
# pip install --force --no-cache --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze
shell: pwsh
- name: Build MSI
run: |
.\venv\Scripts\Activate
cd src
python build.py bdist_msi
shell: pwsh
- name: Get App Info
id: get_version
run: |
.\venv\Scripts\Activate
$version = (Get-Content src/settings.py | Select-String -Pattern 'BUILD_VERSION\s*=\s*"([^"]+)"').Matches.Groups[1].Value
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$filename = (Get-ChildItem -Path src/dist/out/*.msi).Name
echo "FILENAME=$filename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Create Tag
id: create_tag
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PAT }}
script: |
const version = `v${process.env.VERSION}`;
const { owner, repo } = context.repo;
const sha = context.sha;
try {
const { data: tags } = await github.rest.repos.listTags({
owner,
repo,
});
const tagExists = tags.some(tag => tag.name === version);
if (!tagExists) {
console.log(`Creating tag ${version}`);
await github.rest.git.createRef({
owner,
repo,
ref: `refs/tags/${version}`,
sha,
});
} else {
console.log(`Tag ${version} already exists, skipping tag creation`);
}
} catch (error) {
console.error(`Error fetching tags: ${error.message}`);
throw error;
}
- name: Fetch all tags
run: git fetch --tags
shell: pwsh
- name: Create Changelog
id: changelog
uses: loopwerk/tag-changelog@v1.3.0
with:
token: ${{ secrets.PAT }}
config_file: .github/changelog/changelog.js
- name: Generate Checksum
run: |
.\venv\Scripts\Activate
$checksum = Get-FileHash src/dist/out/*.msi -Algorithm SHA256
$filename = [System.IO.Path]::GetFileName($checksum.Path)
"$($checksum.Hash) $filename" > src/dist/out/checksums.txt
shell: pwsh
- name: Create and Upload Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: v${{ env.VERSION }}
body: |
${{ steps.changelog.outputs.changes }}
append_body: true
files: |
src/dist/out/*.msi
src/dist/out/checksums.txt
prerelease: false
generate_release_notes: true
draft: true
env:
GITHUB_TOKEN: ${{ secrets.PAT }}