Build and Release #88
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "8 15 * * 2" | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | |
| RUST_BACKTRACE: full | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| # x86_64-windows-gnu | |
| - arch: ucrt-x86_64-windows-gnu | |
| os: windows-latest | |
| target: amd64 | |
| runs-on: ${{ matrix.os }} | |
| outputs: | |
| latest_tag: ${{ steps.latest_tag.outputs.LA_TAG }} | |
| # latest_rel: ${{ steps.latest_tag.outputs.LA_REL }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: tsukinaha/tsukimi | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Get latest tag and check | |
| id: latest_tag | |
| run: | | |
| # $json = Invoke-WebRequest "https://api.github.com/repos/Kosette/tsukimi/releases/latest" | ConvertFrom-Json | |
| # echo "LA_REL=$($json.tag_name)" >> $ENV:GITHUB_OUTPUT | |
| # echo "LA_TAG=$(git describe --tags --abbrev=0)" >> $ENV:GITHUB_OUTPUT | |
| echo "LA_TAG=v0.21.0" >> $ENV:GITHUB_OUTPUT | |
| - name: Setup msys2 | |
| # if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| update: true | |
| release: false | |
| msystem: UCRT64 | |
| install: >- | |
| mingw-w64-ucrt-x86_64-pkgconf | |
| mingw-w64-ucrt-x86_64-gcc | |
| mingw-w64-ucrt-x86_64-libadwaita | |
| mingw-w64-ucrt-x86_64-gstreamer | |
| mingw-w64-ucrt-x86_64-glib2 | |
| mingw-w64-ucrt-x86_64-gst-plugins-base | |
| mingw-w64-ucrt-x86_64-gst-plugins-good | |
| mingw-w64-ucrt-x86_64-gst-plugins-bad | |
| mingw-w64-ucrt-x86_64-gst-plugins-ugly | |
| mingw-w64-ucrt-x86_64-gst-libav | |
| curl | |
| git | |
| - name: Install latest libmpv | |
| # if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} | |
| shell: pwsh | |
| env: | |
| TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| $json = curl -s "https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/latest" -H "Authorization: Bearer $env:TOKEN" | ConvertFrom-Json | |
| $asset = $json.assets | Where-Object { $_.name -match "mpv-dev-x86_64-\d{8}-git" } | Select-Object -First 1 | |
| curl -L -o $asset.name $asset.browser_download_url | |
| 7z x -y $asset.name -olibmpv | |
| cp -force libmpv/libmpv.dll.a c:/msys64/ucrt64/lib/ | |
| cp -force libmpv/libmpv-2.dll c:/msys64/ucrt64/bin/ | |
| cp -force -recurse libmpv/include/mpv c:/msys64/ucrt64/include/ | |
| - name: Build tsukimi-${{ matrix.arch }} | |
| # if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} | |
| shell: msys2 {0} | |
| run: | | |
| export PATH="/c/Users/runneradmin/.cargo/bin:$PATH" | |
| git reset --hard ${{ steps.latest_tag.outputs.LA_TAG }} | |
| rustup default nightly-gnu | |
| cargo build --release --locked | |
| - name: Prepare Package | |
| # if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} | |
| shell: msys2 {0} | |
| run: | | |
| mkdir artifact && cd artifact | |
| mkdir tsukimi-x86_64-windows-gnu/ && cd tsukimi-x86_64-windows-gnu/ && mkdir bin/ && mkdir share/ && mkdir lib/ | |
| cp $GITHUB_WORKSPACE/target/release/tsukimi.exe bin/ | |
| cp /ucrt64/bin/gdbus.exe bin/ | |
| cp -r /ucrt64/lib/gdk-pixbuf-2.0 lib/ | |
| find lib/gdk-pixbuf-2.0/2.10.0/loaders -type f ! -name "*.dll" -exec rm -f "{}" \; | |
| cp -r /ucrt64/lib/gio lib/ | |
| cp -r /ucrt64/lib/gstreamer-1.0 lib/ && find lib/gstreamer-1.0 -type f ! -name "*.dll" -exec rm -f "{}" \; | |
| cp -r $GITHUB_WORKSPACE/i18n/locale share/ | |
| cp -r /ucrt64/share/glib-2.0 share/ | |
| find share/glib-2.0/* -maxdepth 0 -type d ! -name "*schemas*" -exec rm -rf "{}" \; | |
| mv $GITHUB_WORKSPACE/resources/moe.tsuna.tsukimi.gschema.xml share/glib-2.0/schemas/ | |
| glib-compile-schemas.exe share/glib-2.0/schemas/ | |
| find share/glib-2.0/ -type f ! -name "*.compiled" -exec rm -f "{}" \; | |
| cp -r /ucrt64/share/icons share/ | |
| cp $GITHUB_WORKSPACE/resources/icons/moe.tsuna.tsukimi.png share/icons/ | |
| rm -rf share/icons/hicolor && rm -rf share/icons/AdwaitaLegacy && rm -rf share/icons/Adwaita/scalable && rm -rf share/icons/Adwaita/cursors | |
| rm -rf share/icons/Adwaita/16x16 && rm -rf share/icons/Adwaita/symbolic-up-to-32 | |
| find . -type d -empty -delete | |
| cd lib/gstreamer-1.0 | |
| rm -f \ | |
| libgstadpcmenc.dll libgstamfcodec.dll libgstdvbsubenc.dll libgstencoding.dll \ | |
| libgstfrei0r.dll libgstinter.dll libgstlame.dll libgstldac.dll libgstmpeg2enc.dll \ | |
| libgstmpegpsmux.dll libgstmpegtsmux.dll libgstmplex.dll libgstrealmedia.dll \ | |
| libgstsubenc.dll libgstsvtav1.dll libgstsvthevcenc.dll libgsttwolame.dll \ | |
| libgstvoamrwbenc.dll libgstwavenc.dll libgstx264.dll libgstx265.dll \ | |
| libgstxingmux.dll libgsty4menc.dll libgstzbar.dll | |
| cd $GITHUB_WORKSPACE/artifact/tsukimi-x86_64-windows-gnu | |
| ldd bin/tsukimi.exe | grep '\/ucrt64.*\.dll' -o | xargs -I{} cp -n "{}" bin/ | |
| find lib/ -type f -name "*.dll" -exec ldd "{}" \; | grep '\/ucrt64.*\.dll' -o | xargs -I{} cp -n "{}" bin/ | |
| - name: Create NSIS installer | |
| # if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} | |
| shell: powershell | |
| run: | | |
| choco install nsis | |
| cp ./installer/* artifact | |
| makensis /V4 artifact/tsukimi_installer.nsi | |
| rm artifact/tsukimi_installer.nsi | |
| - name: Build Package | |
| # if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} | |
| shell: powershell | |
| run: | | |
| cd artifact/tsukimi-x86_64-windows-gnu | |
| 7z.exe a ../tsukimi-x86_64-windows-gnu.7z ./* | |
| - name: Upload artifact | |
| # if: ${{ steps.latest_tag.outputs.LA_REL != steps.latest_tag.outputs.LA_TAG }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tsukimi-${{ matrix.arch }} | |
| path: | | |
| artifact/*.exe | |
| artifact/*.7z | |
| compression-level: 0 | |
| retention-days: 3 | |
| if-no-files-found: error | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download artifacts | |
| # if: ${{ needs.build.outputs.latest_tag != needs.build.outputs.latest_rel }} | |
| uses: actions/download-artifact@v4 | |
| - name: Calculate hash | |
| # if: ${{ needs.build.outputs.latest_tag != needs.build.outputs.latest_rel }} | |
| run: | | |
| mv tsukimi-ucrt-x86_64-windows-gnu/* . | |
| sha512sum *.7z > tsukimi.sha512sum | |
| sha512sum *.exe >> tsukimi.sha512sum | |
| - name: Upload Github Assets | |
| # if: ${{ needs.build.outputs.latest_tag != needs.build.outputs.latest_rel }} | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| body: | | |
| > [!IMPORTANT] | |
| > This release is for Windows ONLY. | |
| Full-Changelog: https://github.com/tsukinaha/tsukimi/releases/tag/${{ needs.build.outputs.latest_tag }} | |
| files: | | |
| *.7z | |
| *.exe | |
| tsukimi.sha512sum | |
| tag_name: ${{ needs.build.outputs.latest_tag }} |