Create build.yml #4
This file contains 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 | |
on: | |
push: | |
branches: | |
- main # メインブランチにプッシュされたときに実行 | |
pull_request: | |
branches: | |
- main # メインブランチにプルリクエストが作成されたときに実行 | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest # Linux環境で実行 | |
steps: | |
- uses: actions/checkout@v2 # リポジトリをチェックアウト | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential cmake # 必要なパッケージをインストール | |
- name: Configure and build | |
run: | | |
mkdir build | |
cd build | |
cmake .. | |
cmake --build . | |
- name: Test | |
run: | | |
ctest # テストを実行(必要に応じて) | |
- name: Package binaries | |
run: | | |
cd build | |
zip -r my_project_binaries_linux.zip . | |
- name: Upload release artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: my_project_binaries_linux | |
path: build/my_project_binaries_linux.zip | |
build-windows: | |
runs-on: windows-latest # Windows環境で実行 | |
steps: | |
- uses: actions/checkout@v2 # リポジトリをチェックアウト | |
- name: Install dependencies | |
run: | | |
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' # CMakeをインストール | |
- name: Configure and build | |
run: | | |
mkdir build | |
cd build | |
cmake .. | |
cmake --build . | |
- name: Test | |
run: | | |
ctest # テストを実行(必要に応じて) | |
- name: Package binaries | |
run: | | |
cd build | |
Compress-Archive -Path * -DestinationPath my_project_binaries_windows.zip | |
- name: Upload release artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: my_project_binaries_windows | |
path: build/my_project_binaries_windows.zip | |
build-macos: | |
runs-on: macos-latest # macOS環境で実行 | |
steps: | |
- uses: actions/checkout@v2 # リポジトリをチェックアウト | |
- name: Install dependencies | |
run: | | |
brew install cmake # CMakeをインストール | |
- name: Configure and build | |
run: | | |
mkdir build | |
cd build | |
cmake .. | |
cmake --build . | |
- name: Test | |
run: | | |
ctest # テストを実行(必要に応じて) | |
- name: Package binaries | |
run: | | |
cd build | |
zip -r my_project_binaries_macos.zip . | |
- name: Upload release artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: my_project_binaries_macos | |
path: build/my_project_binaries_macos.zip |