|
| 1 | +name: Build and Release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + # push: |
| 5 | + # branches: ["release"] |
| 6 | + schedule: |
| 7 | + - cron: "8 15 * * *" |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse |
| 12 | + RUST_BACKTRACE: full |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + # x86_64-windows-gnu |
| 20 | + - arch: ucrt-x86_64-windows-gnu |
| 21 | + os: windows-latest |
| 22 | + target: amd64 |
| 23 | + |
| 24 | + runs-on: ${{ matrix.os }} |
| 25 | + |
| 26 | + outputs: |
| 27 | + latest_tag: ${{ steps.latest_tag.outputs.LA_TAG }} |
| 28 | + latest_rel: ${{ steps.latest_tag.outputs.LA_REL }} |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + repository: tsukinaha/tsukimi |
| 35 | + fetch-depth: 0 |
| 36 | + submodules: true |
| 37 | + |
| 38 | + - name: Get latest tag and check |
| 39 | + id: latest_tag |
| 40 | + run: | |
| 41 | + $json = Invoke-WebRequest "https://api.github.com/repos/Kosette/tsukimi/releases/latest" | ConvertFrom-Json |
| 42 | + echo "LA_REL=$($json.tag_name)" >> $ENV:GITHUB_OUTPUT |
| 43 | + echo "LA_TAG=$(git describe --tags --abbrev=0)" >> $ENV:GITHUB_OUTPUT |
| 44 | +
|
| 45 | + - name: Setup msys2 |
| 46 | + if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} |
| 47 | + uses: msys2/setup-msys2@v2 |
| 48 | + with: |
| 49 | + update: true |
| 50 | + release: false |
| 51 | + msystem: UCRT64 |
| 52 | + install: >- |
| 53 | + mingw-w64-ucrt-x86_64-pkgconf |
| 54 | + mingw-w64-ucrt-x86_64-gcc |
| 55 | + mingw-w64-ucrt-x86_64-libadwaita |
| 56 | + mingw-w64-ucrt-x86_64-gstreamer |
| 57 | + mingw-w64-ucrt-x86_64-glib2 |
| 58 | + mingw-w64-ucrt-x86_64-gst-plugins-base |
| 59 | + mingw-w64-ucrt-x86_64-gst-plugins-good |
| 60 | + mingw-w64-ucrt-x86_64-gst-plugins-bad |
| 61 | + mingw-w64-ucrt-x86_64-gst-plugins-ugly |
| 62 | + mingw-w64-ucrt-x86_64-gst-libav |
| 63 | + curl |
| 64 | + git |
| 65 | +
|
| 66 | + - name: Install latest libmpv |
| 67 | + if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} |
| 68 | + shell: pwsh |
| 69 | + env: |
| 70 | + TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + run: | |
| 72 | + $json = curl -s "https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/latest" -H "Authorization: Bearer $env:TOKEN" | ConvertFrom-Json |
| 73 | + $asset = $json.assets | Where-Object { $_.name -match "mpv-dev-x86_64-\d{8}-git" } | Select-Object -First 1 |
| 74 | + curl -L -o $asset.name $asset.browser_download_url |
| 75 | + 7z x -y $asset.name -olibmpv |
| 76 | + cp -force libmpv/libmpv.dll.a c:/msys64/ucrt64/lib/ |
| 77 | + cp -force libmpv/libmpv-2.dll c:/msys64/ucrt64/bin/ |
| 78 | + cp -force -recurse libmpv/include/mpv c:/msys64/ucrt64/include/ |
| 79 | +
|
| 80 | + - name: Build tsukimi-${{ matrix.arch }} |
| 81 | + if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} |
| 82 | + shell: msys2 {0} |
| 83 | + run: | |
| 84 | + export PATH="/c/Users/runneradmin/.cargo/bin:$PATH" |
| 85 | + git reset --hard ${{ steps.latest_tag.outputs.LA_TAG }} |
| 86 | + rustup default stable-gnu |
| 87 | + cargo build --release --locked |
| 88 | +
|
| 89 | + - name: Prepare Package |
| 90 | + if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} |
| 91 | + shell: msys2 {0} |
| 92 | + run: | |
| 93 | + mkdir artifact && cd artifact |
| 94 | + mkdir tsukimi-x86_64-windows-gnu/ && cd tsukimi-x86_64-windows-gnu/ && mkdir bin/ && mkdir share/ && mkdir lib/ |
| 95 | + cp $GITHUB_WORKSPACE/target/release/tsukimi.exe bin/ |
| 96 | + cp /ucrt64/bin/gdbus.exe bin/ |
| 97 | +
|
| 98 | + cp -r /ucrt64/lib/gdk-pixbuf-2.0 lib/ |
| 99 | + find lib/gdk-pixbuf-2.0/2.10.0/loaders -type f ! -name "*.dll" -exec rm -f "{}" \; |
| 100 | +
|
| 101 | + cp -r /ucrt64/lib/gio lib/ |
| 102 | +
|
| 103 | + cp -r /ucrt64/lib/gstreamer-1.0 lib/ && find lib/gstreamer-1.0 -type f ! -name "*.dll" -exec rm -f "{}" \; |
| 104 | +
|
| 105 | + cp -r $GITHUB_WORKSPACE/i18n/locale share/ |
| 106 | +
|
| 107 | + cp -r /ucrt64/share/glib-2.0 share/ |
| 108 | + find share/glib-2.0/* -maxdepth 0 -type d ! -name "*schemas*" -exec rm -rf "{}" \; |
| 109 | + mv $GITHUB_WORKSPACE/resources/moe.tsuna.tsukimi.gschema.xml share/glib-2.0/schemas/ |
| 110 | + glib-compile-schemas.exe share/glib-2.0/schemas/ |
| 111 | + find share/glib-2.0/ -type f ! -name "*.compiled" -exec rm -f "{}" \; |
| 112 | +
|
| 113 | + cp -r /ucrt64/share/icons share/ |
| 114 | + cp $GITHUB_WORKSPACE/resources/icons/moe.tsuna.tsukimi.png share/icons/ |
| 115 | + rm -rf share/icons/hicolor && rm -rf share/icons/AdwaitaLegacy && rm -rf share/icons/Adwaita/scalable && rm -rf share/icons/Adwaita/cursors |
| 116 | + rm -rf share/icons/Adwaita/16x16 && rm -rf share/icons/Adwaita/symbolic-up-to-32 |
| 117 | +
|
| 118 | + find . -type d -empty -delete |
| 119 | +
|
| 120 | + cd lib/gstreamer-1.0 |
| 121 | + rm -f \ |
| 122 | + libgstadpcmenc.dll libgstamfcodec.dll libgstdvbsubenc.dll libgstencoding.dll \ |
| 123 | + libgstfrei0r.dll libgstinter.dll libgstlame.dll libgstldac.dll libgstmpeg2enc.dll \ |
| 124 | + libgstmpegpsmux.dll libgstmpegtsmux.dll libgstmplex.dll libgstrealmedia.dll \ |
| 125 | + libgstsubenc.dll libgstsvtav1.dll libgstsvthevcenc.dll libgsttwolame.dll \ |
| 126 | + libgstvoamrwbenc.dll libgstwavenc.dll libgstx264.dll libgstx265.dll \ |
| 127 | + libgstxingmux.dll libgsty4menc.dll libgstzbar.dll |
| 128 | +
|
| 129 | + cd $GITHUB_WORKSPACE/artifact/tsukimi-x86_64-windows-gnu |
| 130 | + ldd bin/tsukimi.exe | grep '\/ucrt64.*\.dll' -o | xargs -I{} cp -n "{}" bin/ |
| 131 | + find lib/ -type f -name "*.dll" -exec ldd "{}" \; | grep '\/ucrt64.*\.dll' -o | xargs -I{} cp -n "{}" bin/ |
| 132 | +
|
| 133 | + - name: Create NSIS installer |
| 134 | + if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} |
| 135 | + shell: powershell |
| 136 | + run: | |
| 137 | + cp ./installer/* artifact |
| 138 | + makensis /V4 artifact/tsukimi_installer.nsi |
| 139 | + rm artifact/tsukimi_installer.nsi |
| 140 | +
|
| 141 | + - name: Build Package |
| 142 | + if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} |
| 143 | + shell: powershell |
| 144 | + run: | |
| 145 | + cd artifact/tsukimi-x86_64-windows-gnu |
| 146 | + 7z.exe a ../tsukimi-x86_64-windows-gnu.7z ./* |
| 147 | +
|
| 148 | + - name: Upload artifact |
| 149 | + if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} |
| 150 | + uses: actions/upload-artifact@v4 |
| 151 | + with: |
| 152 | + name: tsukimi-${{ matrix.arch }} |
| 153 | + path: | |
| 154 | + artifact/*.exe |
| 155 | + artifact/*.7z |
| 156 | + compression-level: 0 |
| 157 | + retention-days: 3 |
| 158 | + if-no-files-found: error |
| 159 | + |
| 160 | + publish: |
| 161 | + needs: build |
| 162 | + runs-on: ubuntu-latest |
| 163 | + permissions: |
| 164 | + contents: write |
| 165 | + |
| 166 | + steps: |
| 167 | + - name: Download artifacts |
| 168 | + if: ${{ needs.build.outputs.latest_tag != needs.build.outputs.latest_rel }} |
| 169 | + uses: actions/download-artifact@v4 |
| 170 | + |
| 171 | + - name: Calculate hash |
| 172 | + if: ${{ needs.build.outputs.latest_tag != needs.build.outputs.latest_rel }} |
| 173 | + run: | |
| 174 | + mv tsukimi-ucrt-x86_64-windows-gnu/* . |
| 175 | + sha512sum *.7z > tsukimi.sha512sum |
| 176 | + sha512sum *.exe >> tsukimi.sha512sum |
| 177 | +
|
| 178 | + - name: Upload Github Assets |
| 179 | + if: ${{ needs.build.outputs.latest_tag != needs.build.outputs.latest_rel }} |
| 180 | + uses: softprops/action-gh-release@v2 |
| 181 | + env: |
| 182 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 183 | + with: |
| 184 | + body: | |
| 185 | + > [!IMPORTANT] |
| 186 | + > This release is for Windows ONLY. |
| 187 | +
|
| 188 | + Full-Changelog: https://github.com/tsukinaha/tsukimi/releases/tag/${{ needs.build.outputs.latest_tag }} |
| 189 | + files: | |
| 190 | + *.7z |
| 191 | + *.exe |
| 192 | + tsukimi.sha512sum |
| 193 | + tag_name: ${{ needs.build.outputs.latest_tag }} |
0 commit comments