Build and Release #32
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 and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| build_windows: | |
| description: Build Windows x64 executable | |
| required: true | |
| default: true | |
| type: boolean | |
| build_linux: | |
| description: Build Linux x64 package | |
| required: true | |
| default: true | |
| type: boolean | |
| create_release: | |
| description: Create GitHub Release | |
| required: true | |
| default: false | |
| type: boolean | |
| release_tag: | |
| description: "Release tag for manual run (example: v1.3.1)" | |
| required: false | |
| default: '' | |
| type: string | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: build-release-${{ github.ref }} | |
| cancel-in-progress: false | |
| env: | |
| APP_NAME: assignsticker | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| if: github.event_name != 'workflow_dispatch' || inputs.build_windows | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen | |
| uv pip install nuitka | |
| - name: Build Windows executable | |
| run: uv run python build.py --backend nuitka | |
| - name: Upload Windows artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: AssignSticker-windows-x64 | |
| path: release/AssignSticker-windows-x64-*.zip | |
| if-no-files-found: error | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'workflow_dispatch' || inputs.build_linux | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| patchelf \ | |
| python3-dev \ | |
| pkg-config \ | |
| libcairo2-dev \ | |
| gir1.2-gtk-3.0 \ | |
| python3-gi \ | |
| python3-gi-cairo \ | |
| libayatana-appindicator3-1 | |
| sudo apt-get install -y libwebkit2gtk-4.1-0 || sudo apt-get install -y libwebkit2gtk-4.0-37 | |
| sudo apt-get install -y libgirepository-2.0-dev || sudo apt-get install -y libgirepository1.0-dev | |
| sudo apt-get install -y gir1.2-webkit2-4.1 || sudo apt-get install -y gir1.2-webkit2-4.0 | |
| - name: Build Linux package | |
| run: | | |
| uv sync --frozen | |
| uv pip install nuitka | |
| uv run python build.py --backend nuitka | |
| - name: Upload Linux artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: AssignSticker-linux-x64 | |
| path: release/AssignSticker-linux-x64-*.zip | |
| if-no-files-found: error | |
| release: | |
| needs: [build-windows, build-linux] | |
| runs-on: ubuntu-latest | |
| if: | | |
| always() && | |
| (startsWith(github.ref, 'refs/tags/v') || | |
| (github.event_name == 'workflow_dispatch' && inputs.create_release)) && | |
| (needs.build-windows.result == 'success' || needs.build-linux.result == 'success') && | |
| (needs.build-windows.result != 'failure' && needs.build-linux.result != 'failure') | |
| steps: | |
| - name: Resolve release tag | |
| id: rel | |
| shell: bash | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| elif [[ -n "${{ inputs.release_tag }}" ]]; then | |
| TAG="${{ inputs.release_tag }}" | |
| else | |
| echo "Manual release must provide release_tag (example: v1.3.1)" >&2 | |
| exit 1 | |
| fi | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| - name: Download Windows artifact | |
| if: needs.build-windows.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: AssignSticker-windows-x64 | |
| path: artifacts/windows | |
| - name: Download Linux artifact | |
| if: needs.build-linux.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: AssignSticker-linux-x64 | |
| path: artifacts/linux | |
| - name: List release files | |
| run: find artifacts -type f || true | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.rel.outputs.tag }} | |
| files: | | |
| artifacts/windows/* | |
| artifacts/linux/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |