add workflow

This commit is contained in:
yeongpin 2025-02-08 21:57:44 +08:00
parent 7326d0eeb0
commit b61b61c607

92
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,92 @@
name: Build Release
on:
push:
tags:
- 'v*'
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
build_script: build.sh
artifact_name: CursorFreeVIP_linux
- os: macos-latest
build_script: build.mac.command
artifact_name: CursorFreeVIP_mac
- os: windows-latest
build_script: build.bat
artifact_name: CursorFreeVIP_windows.exe
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Get version from tag
id: get_version
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Make scripts executable (Unix)
if: runner.os != 'Windows'
run: |
chmod +x ${{ matrix.build_script }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cmd /c ${{ matrix.build_script }}
else
./${{ matrix.build_script }}
fi
shell: bash
- name: Rename artifacts
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
mv dist/*.exe "dist/CursorFreeVIP_${VERSION}_windows.exe"
elif [ "$RUNNER_OS" == "macOS" ]; then
mv dist/* "dist/CursorFreeVIP_${VERSION}_mac"
else
mv dist/* "dist/CursorFreeVIP_${VERSION}_linux"
fi
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: dist/*
create-release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
CursorFreeVIP_linux/*
CursorFreeVIP_mac/*
CursorFreeVIP_windows.exe/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}