|
| 1 | +# Build for Windows using visual studio |
| 2 | +name: Native Windows release binaries |
| 3 | + |
| 4 | +# Controls when the action will run. Triggers the workflow on push |
| 5 | +on: |
| 6 | + release: |
| 7 | + types: [created] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: ${{ matrix.config.name }} |
| 12 | + runs-on: ${{ matrix.config.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + config: |
| 17 | + - { |
| 18 | + name: "Windows-22", |
| 19 | + os: "windows-2022", |
| 20 | + vs: "2019", |
| 21 | + build_type: "Release" |
| 22 | + } |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v3 |
| 25 | + with: |
| 26 | + ref: ${{ github.ref }} |
| 27 | + # Set up vs studio. Use default windows shell (powershell) not bash, |
| 28 | + # to avoid conflicts with link executable |
| 29 | + - uses: ilammy/msvc-dev-cmd@v1 |
| 30 | + with: |
| 31 | + arch: ${{ runner.arch }} |
| 32 | + vsversion: ${{ matrix.vs }} |
| 33 | + - name: Get ANTs version |
| 34 | + run: | |
| 35 | + $antsVersion="${{ env.ANTS_TAG }}" |
| 36 | + $antsVersion=$antsVersion.Substring(1) |
| 37 | + echo "ANTS_VERSION=$antsVersion" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 38 | + env: |
| 39 | + ANTS_TAG: ${{ github.ref_name }} |
| 40 | + - name: Define env |
| 41 | + run: | |
| 42 | + echo github.event.action: ${{ github.event.action }} |
| 43 | + echo "ARTIFACT=${{ runner.temp }}/ants-${{ env.ANTS_VERSION }}-${{ matrix.config.os }}-${{ runner.arch }}-VS${{ matrix.config.vs }}.zip" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 44 | + - name: Configure |
| 45 | + working-directory: ${{ runner.temp }} |
| 46 | + run: | |
| 47 | + mkdir build |
| 48 | + cd build |
| 49 | + cmake ` |
| 50 | + -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} ` |
| 51 | + -DBUILD_TESTING=ON ` |
| 52 | + -DRUN_SHORT_TESTS=ON ` |
| 53 | + -DRUN_LONG_TESTS=OFF ` |
| 54 | + -DCMAKE_INSTALL_PREFIX:PATH=${{ runner.temp }}/install/ants-${{ env.ANTS_VERSION }} ` |
| 55 | + ${{ github.workspace }} |
| 56 | + - name: Build |
| 57 | + working-directory: ${{ runner.temp }} |
| 58 | + run: | |
| 59 | + cd build |
| 60 | + cmake --build . --config ${{ matrix.config.build_type }} --parallel |
| 61 | + - name: Test |
| 62 | + working-directory: ${{ runner.temp }} |
| 63 | + run: | |
| 64 | + cd build/ANTS-build |
| 65 | + ctest -C release |
| 66 | + - name: Install |
| 67 | + working-directory: ${{ runner.temp }} |
| 68 | + run: | |
| 69 | + cd build/ANTS-build |
| 70 | + cmake --install . |
| 71 | + - name: Pack |
| 72 | + working-directory: ${{ runner.temp }} |
| 73 | + run: | |
| 74 | + cd install |
| 75 | + 7z a ${{ env.ARTIFACT }} . |
| 76 | + - name: Upload release asset |
| 77 | + # Previously was using actions/upload-release-asset@v1 , but this had some |
| 78 | + # errors with large files |
| 79 | + |
| 80 | + with: |
| 81 | + allowUpdates: true |
| 82 | + omitBodyDuringUpdate: true |
| 83 | + omitNameDuringUpdate: true |
| 84 | + artifacts: "${{ env.ARTIFACT }}" |
| 85 | + artifactContentType: application/zip |
| 86 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments