OSDN Git Service

95e9a21990046f47cca2b867e4c35ff9180357de
[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: Fetch tags
40         run: git fetch --tags --force
41         shell: bash
42         working-directory: timidity41
43
44       - name: Run "git describe"
45         run: echo "TIM41_DESCRIBE=$(git describe --first-parent)" >> $GITHUB_ENV
46         shell: bash
47         working-directory: timidity41
48
49       - name: Cache toolchain (x86)
50         id: cache-toolchain-mingw32
51         if: ${{ matrix.arch == 'x86' }}
52         uses: actions/cache@v3
53         with:
54           path: mingw32
55           key: v2023-01-15/gcc-12.2.0_i686-win32-dwarf-ucrt
56
57       - name: Install toolchain (x86)
58         if: ${{ matrix.arch == 'x86' && steps.cache-toolchain-mingw32.outputs.cache-hit != 'true' }}
59         run: |
60           curl.exe -L -O https://github.com/starg2/mingw64-builds-GHA/releases/download/v2023-01-15/gcc-12.2.0_i686-win32-dwarf-ucrt.zip
61           7z e gcc-12.2.0_i686-win32-dwarf-ucrt.zip i686-12.2.0-release-win32-dwarf-ucrt-rt_v11.7z
62           7z x i686-12.2.0-release-win32-dwarf-ucrt-rt_v11.7z
63
64       - name: Cache toolchain (x64)
65         id: cache-toolchain-mingw64
66         if: ${{ matrix.arch == 'x64' }}
67         uses: actions/cache@v3
68         with:
69           path: mingw64
70           key: v2023-01-15/gcc-12.2.0_x86_64-win32-seh-ucrt
71
72       - name: Install toolchain (x64)
73         if: ${{ matrix.arch == 'x64' && steps.cache-toolchain-mingw64.outputs.cache-hit != 'true' }}
74         run: |
75           curl.exe -L -O https://github.com/starg2/mingw64-builds-GHA/releases/download/v2023-01-15/gcc-12.2.0_x86_64-win32-seh-ucrt.zip
76           7z e gcc-12.2.0_x86_64-win32-seh-ucrt.zip x86_64-12.2.0-release-win32-seh-ucrt-rt_v11.7z
77           7z x x86_64-12.2.0-release-win32-seh-ucrt-rt_v11.7z
78
79       - name: Set Toolchain Path
80         run: |
81           "TOOLCHAINDIR=$($env:GITHUB_WORKSPACE -replace '\\', '/')/$(if ('${{ matrix.arch }}' -eq 'x86') { 'mingw32' } else { 'mingw64' })" >> $env:GITHUB_ENV
82           "TOOLCHAINDIR_W=$env:GITHUB_WORKSPACE\$(if ('${{ matrix.arch }}' -eq 'x86') { 'mingw32' } else { 'mingw64' })" >> $env:GITHUB_ENV
83
84       - name: Add PATH
85         run: |
86           $vsdir = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
87           "$vsdir\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" >> $env:GITHUB_PATH
88           "$vsdir\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja" >> $env:GITHUB_PATH
89           "$env:TOOLCHAINDIR_W\bin" >> $env:GITHUB_PATH
90
91       - name: Configure
92         run: >-
93           cmake
94           -G Ninja
95           -DCMAKE_C_COMPILER="$env:TOOLCHAINDIR/bin/gcc.exe"
96           -DCMAKE_CXX_COMPILER="$env:TOOLCHAINDIR/bin/g++.exe"
97           -DCMAKE_BUILD_TYPE=Release
98           -DCMAKE_INSTALL_PREFIX="$($env:GITHUB_WORKSPACE -replace '\\', '/')/timidity41/inst"
99           -DTIM41_X86_SIMD_LEVEL="$('${{ matrix.simd }}'.ToUpperInvariant())"
100           -S timidity41
101           -B timidity41/build
102
103       - name: Build
104         run: ninja -C timidity41\build
105
106       - name: Install
107         run: ninja -C timidity41\build install
108
109       - name: Install runtime DLLs
110         run: >-
111           robocopy
112           "$env:TOOLCHAINDIR_W\bin"
113           timidity41\inst\bin
114           libgcc_s*.dll libstdc++*.dll
115           ; if ($LASTEXITCODE -le 1) { $LASTEXITCODE = 0 }
116
117       - name: Create release archive
118         run: |
119           robocopy timidity41\inst "$env:TIM41_DESCRIBE-${{ matrix.arch }}-${{ matrix.simd }}" /E /XD lib; if ($LASTEXITCODE -le 1) { $LASTEXITCODE = 0 }
120           robocopy "$env:TOOLCHAINDIR_W\licenses\mingw-w64" "$env:TIM41_DESCRIBE-${{ matrix.arch }}-${{ matrix.simd }}" COPYING.MinGW-w64-runtime.txt; if ($LASTEXITCODE -le 1) { $LASTEXITCODE = 0 }
121           7z a "$env:TIM41_DESCRIBE-${{ matrix.arch }}-${{ matrix.simd }}.zip" "$env:TIM41_DESCRIBE-${{ matrix.arch }}-${{ matrix.simd }}"
122
123       - uses: actions/upload-artifact@v3
124         with:
125           name: timidity41-${{ matrix.arch }}-${{ matrix.simd }}
126           path: ${{ env.TIM41_DESCRIBE }}-${{ matrix.arch }}-${{ matrix.simd }}.zip
127
128   release:
129     if: ${{ startsWith(github.ref_name, 'tim41') }}
130     needs: build
131
132     runs-on: ubuntu-latest
133     defaults:
134       run:
135         shell: bash
136
137     permissions:
138       contents: write
139
140     steps:
141       - uses: actions/download-artifact@v3
142         with:
143           path: artifact
144
145       - name: Move artifacts
146         run: mv artifact/timidity41-*/*.zip .
147
148       - name: Generate release name
149         run: echo "RELEASE_NAME=$GITHUB_REF_NAME" | sed 's/tim/TiMidity++ 41 version /' >> $GITHUB_ENV
150
151       - uses: softprops/action-gh-release@v1
152         with:
153           name: ${{ env.RELEASE_NAME }}
154           files: '*.zip'