Files
GenPass/.github/workflows/release.yml
2026-03-10 01:24:27 +04:00

95 lines
2.3 KiB
YAML

name: Build & Release
on:
push:
branches: ["main"]
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
artifact_name: genpass-linux
- os: windows-latest
artifact_name: genpass-windows.exe
- os: macos-latest
artifact_name: genpass-macos
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install -e .
- name: Build executable with PyInstaller
shell: bash
run: |
pyinstaller --onefile --name ${{ matrix.artifact_name }} genpass/cli.py
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: dist/${{ matrix.artifact_name }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate version from commit
id: version
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
else
VERSION="v$(date +%Y.%m.%d)-$(git rev-parse --short HEAD)"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Generated version: $VERSION"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Prepare release assets
shell: bash
run: |
cd artifacts
ls -la
chmod +x * 2>/dev/null || true
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.version }}
files: artifacts/*
generate_release_notes: true
draft: false
prerelease: ${{ startsWith(github.ref, 'refs/tags/') && false || true }}