継続的インテグレーション(CI)
継続的インテグレーション](https://en.wikipedia.org/wiki/Continuous_integration)ワークフローでTuistコマンドを実行するには、CI環境にインストールする必要がある。
認証はオプションだが、キャッシュのようなサーバーサイドの機能を使いたい場合は必須である。
以下のセクションでは、異なるCIプラットフォームでこれを行う方法の例を示す。
例
GitHubアクション
GitHub Actions](https://docs.github.com/en/actions)では、OIDC認証を使うことで、秘密のない安全な認証ができます:
yaml
name: Build Application
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
- run: tuist auth login
- run: tuist setup cacheyaml
name: Build Application
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- run: brew install --formula [email protected]
- run: tuist auth login
- run: tuist setup cacheyaml
name: Build Application
on:
pull_request:
branches:
- main
push:
branches:
- main
env:
TUIST_TOKEN: ${{ secrets.TUIST_TOKEN }}
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
- run: tuist setup cacheyaml
name: Build Application
on:
pull_request:
branches:
- main
push:
branches:
- main
env:
TUIST_TOKEN: ${{ secrets.TUIST_TOKEN }}
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- run: brew install --formula [email protected]
- run: tuist setup cacheOIDC SETUP
OIDC認証を使用する前に、GitHubリポジトリをTuistプロジェクトに接続する必要があります。OIDC を動作させるにはpermissions: id-token: write が必要です。あるいは、TUIST_TOKEN secret を持つ
::: チップ
環境間でTuistのバージョンを固定するために、Tuistプロジェクトでmise use --pin を使用することを推奨する。このコマンドはTuistのバージョンを含む.tool-versions ファイルを作成する。
:::
Xcodeクラウド
Xcodeプロジェクトを真実のソースとして使用するXcode Cloudでは、Tuistをインストールし、必要なコマンドを実行するためにpost-cloneスクリプトを追加する必要があります、例えばtuist generate :
bash
#!/bin/sh
# Mise installation taken from https://mise.jdx.dev/continuous-integration.html#xcode-cloud
curl https://mise.run | sh # Install Mise
export PATH="$HOME/.local/bin:$PATH"
mise install # Installs the version from .mise.toml
# Runs the version of Tuist indicated in the .mise.toml file {#runs-the-version-of-tuist-indicated-in-the-misetoml-file}
mise exec -- tuist install --path ../ # `--path` needed as this is run from within the `ci_scripts` directory
mise exec -- tuist generate -p ../ --no-open # `-p` needed as this is run from within the `ci_scripts` directorybash
#!/bin/sh
brew install --formula [email protected]
tuist generate認証
Xcode Cloud のワークフロー設定でTUIST_TOKEN 環境変数を設定し、プロジェクト・トークン を使用します。
:::
サークルCI
CircleCI](https://circleci.com)では、OIDC認証を使用して、セキュアでシークレットレスな認証を行うことができます:
yaml
version: 2.1
jobs:
build:
macos:
xcode: "15.0.1"
steps:
- checkout
- run:
name: Install Mise
command: |
curl https://mise.jdx.dev/install.sh | sh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $BASH_ENV
- run:
name: Install Tuist
command: mise install
- run:
name: Authenticate
command: mise exec -- tuist auth login
- run:
name: Build
command: mise exec -- tuist setup cacheyaml
version: 2.1
jobs:
build:
macos:
xcode: "15.0.1"
environment:
TUIST_TOKEN: $TUIST_TOKEN
steps:
- checkout
- run:
name: Install Mise
command: |
curl https://mise.jdx.dev/install.sh | sh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $BASH_ENV
- run:
name: Install Tuist
command: mise install
- run:
name: Build
command: mise exec -- tuist setup cache認証
OIDC認証を使用する前に、GitHubリポジトリをTuistプロジェクトに接続する必要があります。CircleCI OIDCトークンには接続したGitHubリポジトリが含まれており、Tuistはこれを使用してプロジェクトへのアクセスを認証します。あるいは、TUIST_TOKEN 環境変数で project token を使用することもできます。
:::
ビットライズ
Bitrise](https://bitrise.io)では、OIDC認証を使用して、セキュアでシークレットレスな認証を行うことができます:
yaml
workflows:
build:
steps:
- git-clone@8: {}
- script@1:
title: Install Mise
inputs:
- content: |
curl https://mise.jdx.dev/install.sh | sh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
- script@1:
title: Install Tuist
inputs:
- content: mise install
- get-identity-token@0:
inputs:
- audience: tuist
- script@1:
title: Authenticate
inputs:
- content: mise exec -- tuist auth login
- script@1:
title: Build
inputs:
- content: mise exec -- tuist setup cacheyaml
workflows:
build:
steps:
- git-clone@8: {}
- script@1:
title: Install Mise
inputs:
- content: |
curl https://mise.jdx.dev/install.sh | sh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
- script@1:
title: Install Tuist
inputs:
- content: mise install
- script@1:
title: Build
inputs:
- content: mise exec -- tuist setup cache認証
OIDC認証を使用する前に、GitHubリポジトリをTuistプロジェクトに接続する必要があります。Bitrise OIDCトークンには接続したGitHubリポジトリが含まれており、Tuistはこれを使用してプロジェクトへのアクセスを認証します。あるいは、TUIST_TOKEN 環境変数で project token を使用することもできます。
:::
コードマジック
Codemagic](https://codemagic.io)では、Tuistをインストールするワークフローに追加のステップを加えることができる:
yaml
workflows:
build:
name: Build
max_build_duration: 30
environment:
xcode: 15.0.1
vars:
TUIST_TOKEN: ${{ secrets.TUIST_TOKEN }}
scripts:
- name: Install Mise
script: |
curl https://mise.jdx.dev/install.sh | sh
mise install # Installs the version from .mise.toml
- name: Build
script: mise exec -- tuist setup cacheyaml
workflows:
build:
name: Build
max_build_duration: 30
environment:
xcode: 15.0.1
vars:
TUIST_TOKEN: ${{ secrets.TUIST_TOKEN }}
scripts:
- name: Install Tuist
script: |
brew install --formula [email protected]
- name: Build
script: tuist setup cache認証
プロジェクト・トークンを作成し、TUIST_TOKEN という秘密の環境変数として追加する。 :::
