Refactor GitHub Actions workflow: rename to 'Build and Release', add … #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Upgrade pip | |
run: | | |
python -m pip install --upgrade pip | |
pip --version | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install wheel | |
pip install -r requirements.txt || pip install google-generativeai | |
- name: Build executable | |
run: | | |
pip install pyinstaller | |
pyinstaller --onefile main.py | |
- name: Generate Release Tag | |
id: create_tag | |
run: | | |
TAG=v1.0.${{ github.run_number }} | |
echo "tag=$TAG" >> $GITHUB_OUTPUT | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.create_tag.outputs.tag }} | |
files: dist/main | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: executable | |
path: dist/main | |
retention-days: 5 |