From bebe45d29bc7ab41f271fbe9d35bfa058daf2112 Mon Sep 17 00:00:00 2001 From: Demmie <2e3s19@gmail.com> Date: Sat, 10 Feb 2024 20:22:38 -0500 Subject: [PATCH] Add Windows installer --- .github/workflows/release.yml | 81 +++++++++++++++++++++++------------ README.md | 14 +++--- windows.nsi | 23 ++++++++++ 3 files changed, 85 insertions(+), 33 deletions(-) create mode 100644 windows.nsi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa106a9..aa34164 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,25 +14,14 @@ defaults: shell: bash jobs: - build: - strategy: - fail-fast: false - matrix: - include: - - target: x86_64-unknown-linux-gnu - # 22.04 is the earliest version with OpenSSL 3 - image: ubuntu-22.04 - build_name: linux - - target: x86_64-pc-windows-msvc - image: windows-latest - build_name: windows - runs-on: ${{ matrix.image }} + build-ubuntu: + # 22.04 is the earliest version with OpenSSL 3 + runs-on: ubuntu-22.04 env: - TARGET: ${{ matrix.target }} + TARGET: x86_64-unknown-linux-gnu steps: - uses: actions/checkout@v3 - name: Install dependencies for Ubuntu - if: ${{ contains(matrix.image, 'ubuntu') }} run: sudo apt-get install -y curl build-essential libdbus-1-dev libssl-dev pkg-config - uses: Swatinem/rust-cache@v2 @@ -41,30 +30,66 @@ jobs: - run: cargo build --release --target $TARGET - name: Compress binary - if: ${{ contains(matrix.image, 'windows') }} - shell: powershell - run: Compress-Archive aw-watcher-media-player.exe aw-watcher-media-player-${{ matrix.build_name }}.zip - working-directory: target/${{ matrix.target }}/release - - - name: Compress binary - if: ${{ !contains(matrix.image, 'windows') }} - run: zip "aw-watcher-media-player-${{ matrix.build_name }}.zip" aw-watcher-media-player - working-directory: target/${{ matrix.target }}/release + run: zip "aw-watcher-media-player-linux.zip" aw-watcher-media-player + working-directory: target/${{ env.TARGET }}/release - name: Upload to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/${{ matrix.target }}/release/aw-watcher-media-player-${{ matrix.build_name }}.zip + file: target/${{ env.TARGET }}/release/aw-watcher-media-player-linux.zip - run: cargo install cargo-deb - if: ${{ contains(matrix.image, 'ubuntu') }} - run: cargo deb - if: ${{ contains(matrix.image, 'ubuntu') }} - name: Upload deb to release - if: ${{ contains(matrix.image, 'ubuntu') }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file_glob: true file: target/debian/aw-*.deb + + build-windows: + runs-on: windows-latest + env: + TARGET: x86_64-pc-windows-msvc + steps: + - uses: actions/checkout@v3 + + - uses: Swatinem/rust-cache@v2 + - name: Install rust target + run: rustup target add $TARGET + - run: cargo build --release --target $TARGET + + - name: Install NSIS + run: choco install nsis + + - name: Setup EnVar Plugin + shell: powershell + run: | + $url = "https://github.com/GsNSIS/EnVar/releases/download/v0.3.1/EnVar-Plugin.zip" + $output = "${{ runner.temp }}\EnVar_plugin.zip" + $nsisDir = "C:\Program Files (x86)\NSIS" + Invoke-WebRequest -Uri $url -OutFile $output + Expand-Archive -Path $output -DestinationPath $nsisDir + Get-ChildItem "C:\Program Files (x86)\NSIS\Plugins" + + - name: Create installer + run: makensis windows.nsi + + - name: Upload installer to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file_glob: true + file: "*.exe" + + - name: Compress binary + shell: powershell + run: Compress-Archive aw-watcher-media-player.exe aw-watcher-media-player-windows.zip + working-directory: target/${{ env.TARGET }}/release + + - name: Upload binary to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/${{ env.TARGET }}/release/aw-watcher-media-player-windows.zip diff --git a/README.md b/README.md index a684583..e7e3adc 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,16 @@ Default Windows player ## Installation -- **Linux**: Run `sudo unzip aw-watcher-media-player-linux.zip -d /usr/local/bin` in the console to allow ActivityWatch to detect its presence, - or install the attached _.deb_ file. +- **Linux**: + - Run `sudo unzip aw-watcher-media-player-linux.zip -d /usr/local/bin` in the console to allow ActivityWatch to detect its presence. + - Or install the attached _.deb_ file. - **Windows**: unpack the executable from `aw-watcher-media-player-windows.zip` into any new folder, - right-click on "Start" -> "System" -> "Advanced system settings" - "Advanced" tab -> "Environment Variables..." -> upper "Edit...", add the new folder path. -- Optionally, add `aw-watcher-media-player-nux` to autostart at `aw-qt/aw-qt.toml` in [config directory](https://docs.activitywatch.net/en/latest/directories.html#config). + **Windows**: + - Run the attached installer executable. + - To install manually and make it available for ActivityWatch, + unpack the executable from `aw-watcher-media-player-windows.zip` into any new folder, + right-click on "Start" -> "System" -> "Advanced system settings" - "Advanced" tab -> "Environment Variables..." -> upper "Edit...", add the new folder path. +- Optionally, add `aw-watcher-media-player` to autostart at `aw-qt/aw-qt.toml` in [config directory](https://docs.activitywatch.net/en/latest/directories.html#config). ## Configuration diff --git a/windows.nsi b/windows.nsi new file mode 100644 index 0000000..850d14f --- /dev/null +++ b/windows.nsi @@ -0,0 +1,23 @@ +OutFile "aw-watcher-media-player-installer.exe" +InstallDir "$LOCALAPPDATA\aw-watcher-media-player" + +RequestExecutionLevel user + +Page directory +Page instfiles + +Section "Install" + SetOutPath $INSTDIR + + File "target\x86_64-pc-windows-msvc\release\aw-watcher-media-player.exe" + + EnVar::AddValue "PATH" "$INSTDIR" +SectionEnd + +Section "Uninstall" + Delete "$INSTDIR\aw-watcher-media-player.exe" + + RMDir "$INSTDIR" + + EnVar::DeleteValue "PATH" "$INSTDIR" +SectionEnd