Add more details to cloth dynamics. #57
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: CMake Build and Release | |
on: | |
push: | |
branches: [main] | |
tags: | |
- "*" | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
include: | |
- os: ubuntu-latest | |
asset_name: DiffCloth-linux-x86_64.zip | |
- os: windows-latest | |
asset_name: DiffCloth-windows-x86_64.zip | |
- os: macos-latest | |
asset_name: DiffCloth-macos-x86_64.zip | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' | |
choco install mingw | |
choco install zip | |
elif [[ "$RUNNER_OS" == "Linux" ]]; then | |
sudo apt-get install -y cmake | |
elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
brew install cmake | |
brew install libomp | |
fi | |
- name: Create Build Directory | |
run: mkdir build | |
- name: Configure CMake | |
working-directory: build | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
cmake .. -G "MinGW Makefiles" | |
else | |
cmake .. | |
fi | |
- name: Build | |
working-directory: build | |
run: cmake --build . --config Release | |
- name: Set permissions | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" != "Windows" ]]; then | |
chmod +x build/DiffCloth* | |
fi | |
- name: Copy libomp.dylib | |
if: matrix.os == 'macos-latest' | |
run: | | |
cp /usr/local/opt/libomp/lib/libomp.dylib build/ | |
- name: Zip Binary and Assets | |
shell: bash | |
run: | | |
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
zip -r ${{ matrix.asset_name }} build/libomp.dylib build/DiffCloth* src/assets README.md LICENSE | |
else | |
zip -r ${{ matrix.asset_name }} build/DiffCloth* src/assets README.md LICENSE | |
fi | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ matrix.asset_name }} | |
path: ${{ matrix.asset_name }} | |
- name: List files in build directory | |
shell: bash | |
run: ls build | |
release: | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v2 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Assets | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
const artifacts = ['DiffCloth-linux-x86_64.zip', 'DiffCloth-windows-x86_64.zip', 'DiffCloth-macos-x86_64.zip']; | |
for (const artifact of artifacts) { | |
const filePath = path.join(process.env.GITHUB_WORKSPACE, artifact); | |
if (fs.existsSync(filePath)) { | |
await github.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: context.payload.release.id, | |
name: path.basename(artifact), | |
data: fs.readFileSync(filePath), | |
headers: { | |
'content-length': fs.statSync(filePath).size, | |
'content-type': 'application/zip', | |
}, | |
}); | |
} | |
} |