Skip to content

Commit

Permalink
Merge pull request #22 from sev-2/feat/windows-installer
Browse files Browse the repository at this point in the history
Enhance Build and Release Workflow
  • Loading branch information
toopay authored May 15, 2024
2 parents 59b3ae7 + 5726790 commit 75782fa
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/*
tags:
- v*

Expand All @@ -13,7 +14,7 @@ jobs:
continue-on-error: true
strategy:
matrix:
goos: [linux, darwin]
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
Expand All @@ -29,12 +30,23 @@ jobs:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
GOOS=$GOOS GOARCH=$GOARCH go build -trimpath -o build/raiden ./cmd/raiden/main.go
VERSION=$([[ ! -z $GITHUB_REF_NAME ]] && echo $GITHUB_REF_NAME || echo $GITHUB_HEAD_NAME)
echo "Raiden version: $VERSION"
sed -i "s,.*appVersion = \".*\"$,\tappVersion = \"$VERSION\"," 'cmd/raiden/commands/version.go'
go build -ldflags="-s -w" -trimpath -o build/raiden ./cmd/raiden/main.go
cd build
if [[ $GOOS == 'darwin' ]]; then
cp raiden raiden-macos-"$GOARCH"
sha256sum -b raiden-macos-"$GOARCH" > raiden-macos-"$GOARCH".sha256
elif [[ $GOOS == 'windows' ]]; then
mv raiden raiden.exe
sudo apt-get install -y nsis
makensis -NOCD -DARCH="$GOARCH" ${GITHUB_WORKSPACE}/scripts/windows.nsi
sha256sum -b raiden-"$GOOS"-"$GOARCH"-setup.exe > raiden-"$GOOS"-"$GOARCH"-setup.exe.sha256
else
cp raiden raiden-"$GOOS"-"$GOARCH"
sha256sum -b raiden-"$GOOS"-"$GOARCH" > raiden-"$GOOS"-"$GOARCH".sha256
fi
- name: Release
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build-linux:
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(CLI_BINARY_NAME)_linux_$(CLI_VERSION) ./cmd/raiden/main.go

build-linux-arm64:
GOOS=linux GOARCH=arm64 go build -o $(BUILD_DIR)/$(CLI_BINARY_NAME)_linux_arm64_$(CLI_VERSION) ./cmd/cli/raiden.go
GOOS=linux GOARCH=arm64 go build -o $(BUILD_DIR)/$(CLI_BINARY_NAME)_linux_arm64_$(CLI_VERSION) ./cmd/raiden/main.go

build-windows:
GOOS=windows GOARCH=amd64 go build -o $(BUILD_DIR)/$(CLI_BINARY_NAME)_windows_$(CLI_VERSION).exe ./cmd/raiden/main.go
Expand All @@ -22,7 +22,7 @@ build-macos:
GOOS=darwin GOARCH=amd64 go build -o $(BUILD_DIR)/$(CLI_BINARY_NAME)_macos_$(CLI_VERSION) ./cmd/raiden/main.go

build-macos-arm64:
GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/$(CLI_BINARY_NAME)_macos_arm64_$(CLI_VERSION) ./cmd/cli/raiden.go
GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/$(CLI_BINARY_NAME)_macos_arm64_$(CLI_VERSION) ./cmd/raiden/main.go

clean:
go clean
Expand Down
34 changes: 34 additions & 0 deletions scripts/windows.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
!include "MUI2.nsh"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

!define NAME "Raiden"
!define APPFILE "raiden.exe"

Name "${NAME}"
Outfile "raiden-windows-${ARCH}-setup.exe"
InstallDir $WINDIR
ShowInstDetails show
RequestExecutionLevel admin

Section
SetOutPath $INSTDIR
File raiden.exe

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Raiden" "DisplayName" "Raiden"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Raiden" "Publisher" "Refactory"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Raiden" "UninstallString" "$\"$INSTDIR\raiden-uninstall.exe$\""

WriteUninstaller $INSTDIR\raiden-uninstall.exe
SectionEnd

Section "Uninstall"
Delete $INSTDIR\raiden.exe
Delete $INSTDIR\raiden-uninstall.exe

DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Raiden"
SectionEnd

0 comments on commit 75782fa

Please sign in to comment.