Skip to content

Commit ddbdea1

Browse files
committed
Release: Windows artifacts on tags
1 parent 2be1adc commit ddbdea1

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Windows release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
runs-on: windows-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Derive version
21+
id: version
22+
shell: bash
23+
run: |
24+
tag="${GITHUB_REF_NAME}"
25+
version="${tag#v}"
26+
echo "version=$version" >> "$GITHUB_OUTPUT"
27+
printf '%s\n' "$version" > VERSION
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.12"
33+
34+
- name: Install dependencies
35+
shell: bash
36+
run: |
37+
python -m pip install --upgrade pip
38+
python -m pip install -r requirements.txt
39+
python -m pip install pyinstaller
40+
41+
- name: Build cvecli.exe (PyInstaller)
42+
shell: bash
43+
run: |
44+
pyinstaller --noconfirm --clean --onefile --name cvecli --add-data "VERSION;." cve_search_cli.py
45+
46+
- name: Create portable zip
47+
shell: pwsh
48+
run: |
49+
New-Item -ItemType Directory -Force -Path dist_pkg | Out-Null
50+
Copy-Item dist\cvecli.exe dist_pkg\
51+
Copy-Item LICENSE dist_pkg\
52+
Copy-Item README.md dist_pkg\
53+
$zip = "cvecli-${{ steps.version.outputs.version }}-windows-x64.zip"
54+
if (Test-Path $zip) { Remove-Item -Force $zip }
55+
Compress-Archive -Path dist_pkg\* -DestinationPath $zip
56+
57+
- name: Create SHA256SUMS
58+
shell: pwsh
59+
run: |
60+
$zip = "cvecli-${{ steps.version.outputs.version }}-windows-x64.zip"
61+
$exe = "dist\\cvecli.exe"
62+
$zipHash = (Get-FileHash -Algorithm SHA256 -Path $zip).Hash.ToLower()
63+
$exeHash = (Get-FileHash -Algorithm SHA256 -Path $exe).Hash.ToLower()
64+
"${exeHash} cvecli.exe" | Out-File -Encoding ascii -NoNewline SHA256SUMS.txt
65+
"`n${zipHash} ${zip}" | Out-File -Encoding ascii -Append SHA256SUMS.txt
66+
67+
- name: Publish GitHub Release assets
68+
uses: softprops/action-gh-release@v2
69+
with:
70+
files: |
71+
dist/cvecli.exe
72+
cvecli-${{ steps.version.outputs.version }}-windows-x64.zip
73+
SHA256SUMS.txt

cve_search_cli.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ def get_version() -> str:
4040
if version:
4141
return version
4242

43+
candidate_dirs: list[Path] = []
44+
meipass = getattr(sys, "_MEIPASS", None)
45+
if meipass:
46+
candidate_dirs.append(Path(meipass))
47+
candidate_dirs.append(Path(__file__).resolve().parent)
48+
49+
for directory in candidate_dirs:
50+
try:
51+
version_file = directory / "VERSION"
52+
if version_file.is_file():
53+
file_version = version_file.read_text(encoding="utf-8").strip()
54+
if file_version:
55+
return file_version
56+
except Exception:
57+
pass
58+
4359
try:
4460
script_dir = Path(__file__).resolve().parent
4561
result = subprocess.run(

0 commit comments

Comments
 (0)