Build Karbon and Release #21
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
| name: Build Karbon and Release | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| include: | |
| - os: windows-latest | |
| extension: .exe | |
| pyinstaller-args: "--onefile --noconsole --name Karbon --icon=icon.ico" | |
| - os: ubuntu-latest | |
| extension: '' | |
| pyinstaller-args: "--onefile --name Karbon" | |
| - os: macos-latest | |
| extension: .app | |
| pyinstaller-args: "--onefile --windowed --name Karbon" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| - name: Build executable with PyInstaller | |
| run: | | |
| python -m PyInstaller ui.py ${{ matrix.pyinstaller-args }} | |
| - name: Rename binary for upload | |
| shell: bash | |
| run: | | |
| mkdir -p upload | |
| if [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
| cp -r "dist/Karbon.app" "upload/Karbon-${{ runner.os }}.app" | |
| else | |
| cp "dist/Karbon${{ matrix.extension }}" "upload/Karbon-${{ runner.os }}${{ matrix.extension }}" | |
| fi | |
| - name: Zip output for Linux/macOS | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| cd upload | |
| zip -r Karbon-${{ runner.os }}.zip ./* | |
| - name: Get short commit hash | |
| id: vars | |
| shell: bash | |
| run: echo "SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_ENV | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: "build-${{ env.SHORT_SHA }}" | |
| name: "Karbon Build ${{ env.SHORT_SHA }}" | |
| draft: false | |
| prerelease: false | |
| files: | | |
| upload/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload build artifacts (backup) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: karbon-${{ runner.os }} | |
| path: upload/* | |