Build and Deploy Executables #1
Workflow file for this run
This file contains hidden or 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
| # .github/workflows/build_deploy_executables.yml | |
| name: Build and Deploy Executables | |
| on: | |
| release: | |
| types: [published] # Release가 'published' 상태가 될 때 트리거 | |
| jobs: | |
| # 1단계: 각 OS에서 실행 파일을 빌드하는 잡 | |
| build: | |
| strategy: | |
| matrix: | |
| os: [macos-latest, windows-latest] # macOS와 Windows 환경에서 각각 빌드 | |
| runs-on: ${{ matrix.os }} # 매트릭스에서 선택된 OS에서 잡 실행 | |
| steps: | |
| # 1. Git 리포지토리의 소스 코드를 가져옵니다. | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2. Poetry를 사용하여 파이썬 환경을 설정합니다. | |
| - name: Set up Python with Poetry | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "poetry" | |
| # 3. Poetry 의존성(PyInstaller 포함)을 설치합니다. | |
| - name: Install Poetry dependencies | |
| run: poetry install --no-root | |
| # 4. OS에 따라 실행 파일의 이름(.exe 확장자 등)을 결정합니다. | |
| - name: Set executable name | |
| id: set_name | |
| shell: bash | |
| run: | | |
| if [ "${{ runner.os }}" == "macOS" ]; then | |
| echo "EXE_NAME=askql-ai" >> $GITHUB_ENV | |
| elif [ "${{ runner.os }}" == "Windows" ]; then | |
| echo "EXE_NAME=askql-ai.exe" >> $GITHUB_ENV | |
| fi | |
| # 6. PyInstaller를 사용해 파이썬 코드를 실행 파일로 만듭니다. | |
| - name: Build executable with PyInstaller | |
| run: pyinstaller src/main.py --name ${{ env.EXE_NAME }} --onefile --noconsole | |
| # 7. 빌드된 실행 파일을 다음 단계(deploy)에서 사용할 수 있도록 아티팩트로 업로드합니다. | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: executable-${{ runner.os }} | |
| path: dist/${{ env.EXE_NAME }} | |
| retention-days: 1 # 아티팩트 보관 기간 (하루) | |
| # 2단계: 빌드된 실행 파일들을 Front 리포지토리에 배포하는 잡 | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Front Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: AskQL/askql_app | |
| token: ${{ secrets.PAT_FOR_FRONT_REPO }} | |
| ref: develop | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Organize files | |
| run: | | |
| mkdir -p resources/mac resources/win | |
| mv artifacts/executable-macOS/askql-api resources/mac/ | |
| mv artifacts/executable-Windows/askql-api.exe resources/win/ | |
| - name: Commit and push changes | |
| run: | | |
| git config --global user.name 'github-actions' | |
| git config --global user.email '[email protected]' | |
| git add . | |
| # 변경 사항이 있을 때만 커밋 및 푸시 | |
| if git diff-index --quiet HEAD; then | |
| echo "No changes to commit to AskQL APP repository." | |
| else | |
| git commit -m "feat: API 실행 파일 업데이트 (${{ github.ref_name }})" | |
| git push | |
| fi |