Skip to content

Commit

Permalink
Add Windows installer
Browse files Browse the repository at this point in the history
  • Loading branch information
2e3s committed Feb 19, 2024
1 parent cb5880e commit b3aaec0
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 28 deletions.
86 changes: 58 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ permissions:
contents: write
on:
push:
branches:
- main
tags:
- 'v[0-9]*.*.*'
env:
Expand All @@ -14,25 +16,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
Expand All @@ -41,30 +32,69 @@ 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
overwrite: 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
overwrite: 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
overwrite: true
23 changes: 23 additions & 0 deletions windows.nsi
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b3aaec0

Please sign in to comment.