|
| 1 | +name: Build For Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + name: Test (Windows) |
| 10 | + runs-on: windows-latest |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + config: [Release, Debug] |
| 15 | + arch: [x64, x86] |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + submodules: recursive |
| 21 | + |
| 22 | + - name: Download Foobar2000 SDK |
| 23 | + run: | |
| 24 | + curl -L https://www.foobar2000.org/files/SDK-2023-09-23.7z -o vendor/foobar2000_sdk.7z |
| 25 | + 7z x vendor/foobar2000_sdk.7z -ovendor/sdk |
| 26 | + ls vendor/sdk |
| 27 | +
|
| 28 | + - name: Setup Msbuild |
| 29 | + uses: microsoft/setup-msbuild@v2 |
| 30 | + |
| 31 | + - name: Restore NuGet packages |
| 32 | + working-directory: ${{ github.workspace }} |
| 33 | + run: nuget restore foo_input_ncm.sln |
| 34 | + |
| 35 | + - name: Build Test Executable |
| 36 | + working-directory: ${{ github.workspace }} |
| 37 | + run: | |
| 38 | + msbuild foo_input_ncm.sln -property:"Configuration=${{ matrix.config }};Platform=${{ matrix.arch}}" -target:foo_input_ncm_tests |
| 39 | +
|
| 40 | + - name: Run Tests (x86) |
| 41 | + working-directory: ${{ github.workspace }}/${{ matrix.config }} |
| 42 | + run: .\foo_input_ncm_tests.exe |
| 43 | + if: matrix.arch == 'x86' |
| 44 | + |
| 45 | + - name: Run Tests (x64) |
| 46 | + working-directory: ${{ github.workspace }}/${{ matrix.arch }}/${{ matrix.config }} |
| 47 | + run: .\foo_input_ncm_tests.exe |
| 48 | + if: matrix.arch == 'x64' |
| 49 | + |
| 50 | + matrix-build: |
| 51 | + name: Matrix Build |
| 52 | + runs-on: ${{ matrix.os }} |
| 53 | + needs: [test] |
| 54 | + strategy: |
| 55 | + fail-fast: false |
| 56 | + matrix: |
| 57 | + os: [windows-latest, macos-14] |
| 58 | + config: [Release] |
| 59 | + arch: [x64, x86] |
| 60 | + exclude: |
| 61 | + - os: macos-14 |
| 62 | + arch: x86 |
| 63 | + include: |
| 64 | + - os: windows-latest |
| 65 | + build-command: msbuild |
| 66 | + solution: foo_input_ncm.sln |
| 67 | + - os: macos-14 |
| 68 | + build-command: xcodebuild |
| 69 | + workspace: foo_input_ncm.xcworkspace |
| 70 | + project: foo_input_ncm.xcodeproj |
| 71 | + |
| 72 | + steps: |
| 73 | + - name: Checkout |
| 74 | + uses: actions/checkout@v4 |
| 75 | + with: |
| 76 | + submodules: recursive |
| 77 | + fetch-tags: true |
| 78 | + fetch-depth: 0 |
| 79 | + |
| 80 | + - name: Versioning |
| 81 | + run: | |
| 82 | + TAG=$(git describe --tags) |
| 83 | + VERSION=${TAG:1} |
| 84 | + echo "#define CURRENT_VERSION $VERSION" >> src/stdafx.h |
| 85 | + echo "----------------------------" |
| 86 | + cat src/stdafx.h |
| 87 | + shell: bash |
| 88 | + working-directory: ${{ github.workspace }} |
| 89 | + |
| 90 | + - name: Download Foobar2000 SDK |
| 91 | + run: | |
| 92 | + curl -L https://www.foobar2000.org/files/SDK-2023-09-23.7z -o vendor/foobar2000_sdk.7z |
| 93 | + 7z x vendor/foobar2000_sdk.7z -ovendor/sdk |
| 94 | + ls vendor/sdk |
| 95 | +
|
| 96 | + - name: (XCode) Switch XCode Version |
| 97 | + run: | |
| 98 | + sudo xcode-select --switch /Applications/Xcode_15.3.app |
| 99 | + xcodebuild -version |
| 100 | + if: matrix.os == 'macos-14' |
| 101 | + |
| 102 | + - name: (XCode) List Scheme |
| 103 | + run: | |
| 104 | + xcodebuild -list -workspace ${{ matrix.workspace }} |
| 105 | + echo Build with scheme: foo_input_ncm-${{ matrix.config }} |
| 106 | + if: matrix.os == 'macos-14' |
| 107 | + |
| 108 | + - name: (XCode) Build component bundle |
| 109 | + env: |
| 110 | + scheme: foo_input_ncm-${{ matrix.config }} |
| 111 | + run: | |
| 112 | + xcodebuild clean build -workspace ${{ matrix.workspace }} -scheme "$scheme" -configuration ${{ matrix.config }} |
| 113 | + if: matrix.os == 'macos-14' |
| 114 | + |
| 115 | + - name: (MSBuild) Setup MSBuild |
| 116 | + uses: microsoft/setup-msbuild@v2 |
| 117 | + if: matrix.os == 'windows-latest' |
| 118 | + |
| 119 | + - name: (MSBuild) Restore NuGet packages |
| 120 | + working-directory: ${{ github.workspace }} |
| 121 | + run: nuget restore ${{ matrix.solution }} |
| 122 | + if: matrix.os == 'windows-latest' |
| 123 | + |
| 124 | + - name: (MSBuild) Build component dll |
| 125 | + working-directory: ${{ github.workspace }} |
| 126 | + run: msbuild ${{ matrix.solution }} -property:"Configuration=${{ matrix.config }};Platform=${{ matrix.arch}}" -target:foo_input_ncm |
| 127 | + if: matrix.os == 'windows-latest' |
| 128 | + |
| 129 | + - name: Upload Artifacts |
| 130 | + uses: actions/upload-artifact@v4 |
| 131 | + with: |
| 132 | + name: dist-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.config }} |
| 133 | + path: ${{ github.workspace }}/dist |
| 134 | + if-no-files-found: error |
| 135 | + pack: |
| 136 | + name: Make fb2k-componet package |
| 137 | + runs-on: ubuntu-latest |
| 138 | + needs: matrix-build |
| 139 | + steps: |
| 140 | + - name: Download Artifacts (MacOS bundle) |
| 141 | + uses: actions/download-artifact@v4 |
| 142 | + with: |
| 143 | + pattern: dist-macos-*-Release |
| 144 | + |
| 145 | + - name: Download Artifacts (Windows dll) |
| 146 | + uses: actions/download-artifact@v4 |
| 147 | + with: |
| 148 | + pattern: dist-windows-*-Release |
| 149 | + |
| 150 | + - name: Touch Directories |
| 151 | + run: | |
| 152 | + mkdir -p win32/x64 |
| 153 | + mkdir -p macos/mac |
| 154 | + working-directory: ${{ github.workspace }} |
| 155 | + |
| 156 | + - name: Pack component - Windows |
| 157 | + run: | |
| 158 | + cp ${{ github.workspace }}/dist-windows-latest-x86-Release/foo_input_ncm.dll . |
| 159 | + cp -r ${{ github.workspace }}/dist-windows-latest-x64-Release/x64 . |
| 160 | + zip -r ${{ github.workspace }}/foo_input_ncm-win32.fb2k-component ./* |
| 161 | + working-directory: ${{ github.workspace }}/win32 |
| 162 | + |
| 163 | + - name: Pack component - MacOS |
| 164 | + run: | |
| 165 | + cp -r ${{ github.workspace }}/dist-macos-14-x64-Release/mac . |
| 166 | + zip -r ${{ github.workspace }}/foo_input_ncm-macos.fb2k-component ./* |
| 167 | + working-directory: ${{ github.workspace }}/macos |
| 168 | + |
| 169 | + - name: Upload Artifacts |
| 170 | + uses: actions/upload-artifact@v4 |
| 171 | + with: |
| 172 | + name: packages |
| 173 | + path: '${{ github.workspace }}/*.fb2k-component' |
| 174 | + |
| 175 | + release: |
| 176 | + name: Publish Release |
| 177 | + runs-on: ubuntu-latest |
| 178 | + needs: pack |
| 179 | + if: (github.event_name == 'workflow_dispatch') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) |
| 180 | + steps: |
| 181 | + - name: Download Artifacts |
| 182 | + uses: actions/download-artifact@v4 |
| 183 | + with: |
| 184 | + name: packages |
| 185 | + |
| 186 | + - name: Upload to Release |
| 187 | + uses: softprops/action-gh-release@v2 |
| 188 | + with: |
| 189 | + files: ${{ github.workspace }}/*.fb2k-component |
| 190 | + make_latest: true |
| 191 | + generate_release_notes: true |
0 commit comments