OSDN Git Service

[actions] Split CMake options
[timidity41/timidity41.git] / .github / workflows / build.yml
1
2 name: build
3
4 on:
5   push:
6     branches-ignore:
7       - 'develop'
8       - 'master'
9       - 'unkotim'
10     tags:
11       - 'tim*'
12
13   pull_request:
14     types:
15       - opened
16       - reopened
17       - synchronize
18
19   workflow_dispatch:
20
21 jobs:
22   build:
23     strategy:
24       matrix:
25         arch: ['x86', 'x64']
26         simd: ['sse42', 'avx', 'avx2', 'avx512']
27
28     runs-on: windows-latest
29     defaults:
30       run:
31         shell: pwsh
32
33     steps:
34       - uses: actions/checkout@v3
35         with:
36           path: timidity41
37           fetch-depth: 0
38
39       - name: Run "git describe"
40         run: echo "TIM41_DESCRIBE=$(git describe --first-parent)" >> $GITHUB_ENV
41         shell: bash
42         working-directory: timidity41
43
44       - name: Install toolchain
45         run: |
46           curl.exe -L -O https://github.com/starg2/mingw64-builds-GHA/releases/download/v2022-09-24/gcc-12.2.0_x86_64-win32-sjlj-ucrt.zip
47           7z x gcc-12.2.0_x86_64-win32-sjlj-ucrt.zip
48           7z x x86_64-12.2.0-static-release-win32-sjlj-rt_v10.7z
49
50       - name: Add PATH
51         run: |
52           $vsdir = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
53           "$vsdir\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" >> $env:GITHUB_PATH
54           "$vsdir\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja" >> $env:GITHUB_PATH
55           "$env:GITHUB_WORKSPACE\mingw64\bin" >> $env:GITHUB_PATH
56
57       - name: Configure
58         run: >-
59           cmake
60           -G Ninja
61           -DCMAKE_C_COMPILER="$($env:GITHUB_WORKSPACE -replace '\\', '/')/mingw64/bin/gcc.exe"
62           -DCMAKE_CXX_COMPILER="$($env:GITHUB_WORKSPACE -replace '\\', '/')/mingw64/bin/g++.exe"
63           $(if ('${{ matrix.arch }}' -eq 'x86') { '-DCMAKE_C_FLAGS="-m32"' })
64           $(if ('${{ matrix.arch }}' -eq 'x86') { '-DCMAKE_CXX_FLAGS="-m32"' })
65           $(if ('${{ matrix.arch }}' -eq 'x86') { '-DCMAKE_RC_FLAGS="--target=pe-i386"' })
66           -DCMAKE_BUILD_TYPE=Release
67           -DCMAKE_INSTALL_PREFIX="$($env:GITHUB_WORKSPACE -replace '\\', '/')/timidity41/inst"
68           -DTIM41_X86_SIMD_LEVEL="$('${{ matrix.simd }}'.ToUpperInvariant())"
69           -S timidity41
70           -B timidity41/build
71
72       - name: Copy runtime DLLs
73         if: ${{ matrix.arch == 'x86' }}
74         run: >-
75           robocopy
76           mingw64\x86_64-w64-mingw32\lib32
77           timidity41\build\out\bin
78           libgcc_s*.dll libstdc++*.dll
79           ; if ($LASTEXITCODE -le 1) { $LASTEXITCODE = 0 } else { $LASTEXITCODE = 1 }
80
81       - name: Build
82         run: ninja -C timidity41\build
83
84       - name: Install
85         run: ninja -C timidity41\build install
86
87       - name: Install runtime DLLs
88         run: >-
89           robocopy
90           "mingw64\x86_64-w64-mingw32\$(if ('${{ matrix.arch }}' -eq 'x86') { 'lib32' } else { 'lib' })"
91           timidity41\inst\bin
92           libgcc_s*.dll libstdc++*.dll
93           ; if ($LASTEXITCODE -le 1) { $LASTEXITCODE = 0 } else { $LASTEXITCODE = 1 }
94
95       - name: Create release archive
96         run: |
97           robocopy timidity41\inst "$env:TIM41_DESCRIBE-${{ matrix.arch }}-${{ matrix.simd }}" /E /XD lib; if ($LASTEXITCODE -le 1) { $LASTEXITCODE = 0 } else { $LASTEXITCODE = 1 }
98           robocopy mingw64\licenses\mingw-w64 "$env:TIM41_DESCRIBE-${{ matrix.arch }}-${{ matrix.simd }}" COPYING.MinGW-w64-runtime.txt; if ($LASTEXITCODE -le 1) { $LASTEXITCODE = 0 } else { $LASTEXITCODE = 1 }
99           7z a "$env:TIM41_DESCRIBE-${{ matrix.arch }}-${{ matrix.simd }}.zip" "$env:TIM41_DESCRIBE-${{ matrix.arch }}-${{ matrix.simd }}"
100
101       - uses: actions/upload-artifact@v3
102         with:
103           name: timidity41-${{ matrix.arch }}-${{ matrix.simd }}
104           path: ${{ env.TIM41_DESCRIBE }}-${{ matrix.arch }}-${{ matrix.simd }}.zip
105
106   release:
107     if: ${{ startsWith(github.ref_name, 'tim41') }}
108     needs: build
109
110     runs-on: ubuntu-latest
111     defaults:
112       run:
113         shell: bash
114
115     permissions:
116       contents: write
117
118     steps:
119       - uses: actions/download-artifact@v3
120         with:
121           path: artifact
122
123       - name: Move artifacts
124         run: mv artifact/timidity41-*/*.zip .
125
126       - name: Generate release name
127         run: echo "RELEASE_NAME='$GITHUB_REF_NAME'" | sed 's/tim/TiMidity++ Version v/' >> $GITHUB_ENV
128
129       - uses: softprops/action-gh-release@v1
130         with:
131           name: ${{ env.RELEASE_NAME }}
132           files: '*.zip'