|
| 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 |
0 commit comments