Fix: [GitHub][workflows] ca-certificates がないと HTTPS URL から DL できないのを忘… #189
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 Installer | |
| # installer/ 以下のファイルに変更があったとき or | |
| # .github/workflows/build_installer.yaml (このファイル) に変更があったとき or 他のワークフローからの呼び出し or 手動実行 | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - 'installer/**' | |
| - '.github/workflows/build_installer.yaml' | |
| workflow_call: | |
| workflow_dispatch: | |
| env: | |
| # Python のバージョン (Python Standalone Builds のリリースを指定する) | |
| ## ref: https://github.com/indygreg/python-build-standalone/releases | |
| PYTHON_TAG: '20251031' | |
| PYTHON_MAJOR_VERSION: '3.11' | |
| PYTHON_VERSION: '3.11.14' | |
| # Poetry のバージョン | |
| POETRY_VERSION: '1.8.5' | |
| # ジョブの定義 | |
| jobs: | |
| # Windows 向けのインストーラーのビルド | |
| build-windows: | |
| runs-on: windows-2022 | |
| steps: | |
| # KonomiTV のソースコードをチェックアウト | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| # Python 3.11 環境をセットアップ | |
| ## 事前に Runner 自体に入っている Python に Poetry をインストールしておく必要がある | |
| - name: Install Poetry (for Runner) | |
| run: | | |
| python -m pip install poetry | |
| - name: Setup Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'poetry' | |
| cache-dependency-path: '${{ github.workspace }}/installer/poetry.lock' | |
| # インストーラーの依存関係をインストール | |
| - name: Install Dependencies | |
| working-directory: installer/ | |
| run: | | |
| pip install poetry | |
| poetry install --no-root | |
| # インストーラーを PyInstaller でビルド | |
| - name: Build Installer with PyInstaller | |
| working-directory: installer/ | |
| run: poetry run task build-windows | |
| # 単一実行ファイルにビルドされたインストーラーを Artifact としてアップロード | |
| - name: Upload Installer Executable as Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: KonomiTV-Installer.exe | |
| path: installer/dist/KonomiTV-Installer.exe | |
| # Linux 向けのインストーラーのビルド | |
| build-linux: | |
| strategy: | |
| fail-fast: false # 一つのビルドが失敗しても他のビルドは継続する | |
| matrix: | |
| include: | |
| # x64 アーキテクチャ向けのビルド設定 | |
| - arch: amd64 | |
| runner: ubuntu-22.04 | |
| artifact_suffix: '' | |
| # x86_64_v2 にすると2008年以降の CPU に搭載されている SSE 命令が使える | |
| # ref: https://gregoryszorc.com/docs/python-build-standalone/main/running.html | |
| python_arch_name: x86_64_v2 | |
| # arm64 アーキテクチャ向けのビルド設定 | |
| - arch: arm64 | |
| runner: ubuntu-22.04-arm | |
| artifact_suffix: '-ARM' | |
| python_arch_name: aarch64 | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| # Docker Buildx のセットアップ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Dockerfile を作成 | |
| # Python Standalone Builds を使用して Python 3.11 をインストールする | |
| - name: Create Dockerfile | |
| run: | | |
| cat <<EOF > Dockerfile | |
| FROM ubuntu:20.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # build-essential, curl, zlib, ca-certificates などの必要なパッケージをインストール | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| ca-certificates \ | |
| curl \ | |
| zlib1g \ | |
| zlib1g-dev | |
| # Python Standalone Builds をダウンロードしてインストール | |
| RUN curl -L -o python.tar.gz https://github.com/indygreg/python-build-standalone/releases/download/${{ env.PYTHON_TAG }}/cpython-${{ env.PYTHON_VERSION }}+${{ env.PYTHON_TAG }}-${{ matrix.python_arch_name }}-unknown-linux-gnu-install_only_stripped.tar.gz && \ | |
| tar xvf python.tar.gz && \ | |
| mv python /usr/local/python && \ | |
| rm python.tar.gz | |
| # Python をパスの通った場所にシンボリックリンクで配置 | |
| RUN ln -s /usr/local/python/bin/python3 /usr/local/bin/python3 && \ | |
| ln -s /usr/local/python/bin/python3 /usr/local/bin/python3.11 && \ | |
| ln -s /usr/local/python/bin/python3 /usr/local/bin/python && \ | |
| ln -s /usr/local/python/bin/pip3 /usr/local/bin/pip3 && \ | |
| ln -s /usr/local/python/bin/pip3 /usr/local/bin/pip | |
| # poetry をインストール | |
| RUN python3.11 -m pip install poetry==${{ env.POETRY_VERSION }} | |
| # poetry をパスの通った場所にシンボリックリンクで配置 | |
| RUN ln -s /usr/local/python/bin/poetry /usr/local/bin/poetry | |
| EOF | |
| # Ubuntu 20.04 の Docker イメージをビルド | |
| - name: Build Docker Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| tags: ubuntu:20.04-custom | |
| cache-from: type=gha,scope=ubuntu:20.04-custom(${{ matrix.arch }}) | |
| cache-to: type=gha,scope=ubuntu:20.04-custom(${{ matrix.arch }}),mode=max | |
| load: true | |
| # Dockerfile を削除 | |
| - name: Remove Dockerfile | |
| run: rm Dockerfile | |
| # KonomiTV のソースコードをチェックアウト | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| # インストーラーを PyInstaller でビルド | |
| # arm64 ビルドではリリースでの区別のため、ファイル名を KonomiTV-Installer-ARM.elf に変更する | |
| - name: Build Installer with PyInstaller | |
| working-directory: installer/ | |
| run: | | |
| docker run --rm -i -v $(pwd):/work -w /work ubuntu:20.04-custom bash -c \ | |
| 'poetry install --no-root && poetry run task build-linux' | |
| if [ "${{ matrix.arch }}" == "arm64" ]; then | |
| echo "Renaming artifact for ARM build..." | |
| sudo mv dist/KonomiTV-Installer.elf dist/KonomiTV-Installer-ARM.elf | |
| fi | |
| # 単一実行ファイルにビルドされたインストーラーを Artifact としてアップロード | |
| # matrix の設定に応じてファイル名とパスを動的に変更 | |
| - name: Upload Installer Executable as Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: KonomiTV-Installer${{ matrix.artifact_suffix }}.elf | |
| path: installer/dist/KonomiTV-Installer${{ matrix.artifact_suffix }}.elf |