|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]+.*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + packages: read |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + create_release: |
| 14 | + name: Create Release |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + outputs: |
| 18 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Create Release |
| 22 | + id: create_release |
| 23 | + uses: actions/create-release@v1 |
| 24 | + env: |
| 25 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + with: |
| 27 | + tag_name: ${{ github.ref }} |
| 28 | + release_name: Release ${{ github.ref }} |
| 29 | + draft: false |
| 30 | + prerelease: false |
| 31 | + |
| 32 | + release_assets: |
| 33 | + name: Release Assets |
| 34 | + needs: create_release |
| 35 | + runs-on: ${{ matrix.os }} |
| 36 | + |
| 37 | + strategy: |
| 38 | + matrix: |
| 39 | + os: [ubuntu-latest, windows-latest] |
| 40 | + build_type: [Release] |
| 41 | + cpp_compiler: [g++, cl] |
| 42 | + include: |
| 43 | + - os: windows-latest |
| 44 | + cpp_compiler: cl |
| 45 | + - os: ubuntu-latest |
| 46 | + cpp_compiler: g++ |
| 47 | + exclude: |
| 48 | + - os: windows-latest |
| 49 | + cpp_compiler: g++ |
| 50 | + - os: ubuntu-latest |
| 51 | + cpp_compiler: cl |
| 52 | + |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v3 |
| 55 | + |
| 56 | + - name: Set Reusable Strings |
| 57 | + id: strings |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" |
| 61 | +
|
| 62 | + - name: Configure CMake |
| 63 | + run: > |
| 64 | + cmake -B ${{ steps.strings.outputs.build-output-dir }} |
| 65 | + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} |
| 66 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 67 | + -S ${{ github.workspace }} |
| 68 | +
|
| 69 | + - name: Build |
| 70 | + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} |
| 71 | + |
| 72 | + - name: Upload Ubuntu Assets |
| 73 | + if: ${{ matrix.os == 'ubuntu-latest' }} |
| 74 | + uses: actions/upload-release-asset@v1 |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + with: |
| 78 | + upload_url: ${{ needs.create_release.outputs.upload_url }} |
| 79 | + asset_name: vtrex |
| 80 | + asset_path: ${{ steps.strings.outputs.build-output-dir }}/vtrex |
| 81 | + asset_content_type: application/octet-stream |
| 82 | + |
| 83 | + - name: Upload Windows Assets |
| 84 | + if: ${{ matrix.os == 'windows-latest' }} |
| 85 | + uses: actions/upload-release-asset@v1 |
| 86 | + env: |
| 87 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + with: |
| 89 | + upload_url: ${{ needs.create_release.outputs.upload_url }} |
| 90 | + asset_name: vtrex.exe |
| 91 | + asset_path: ${{ steps.strings.outputs.build-output-dir }}/Release/vtrex.exe |
| 92 | + asset_content_type: application/octet-stream |
0 commit comments