Skip to content

Commit

Permalink
updated releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
mt190502 committed Sep 14, 2023
1 parent c6d69cd commit 7fb6e0f
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 14 deletions.
48 changes: 36 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,53 @@ on:
permissions:
contents: write
# packages: write
# issues: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: pull repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4

- name: git fetch
run: git fetch --force --tags

- name: setup go
uses: actions/setup-go@v4
with:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- uses: goreleaser/goreleaser-action@v4

- name: set version in main.go
run: sed -i "s/rest.StartServer(c.Port, \"1.0.0\")/rest.StartServer(c.Port, \"$(git tag | sort -Vr | head -n 1)\")/g" $PWD/main.go

- name: build go
uses: goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
version: latest
args: release --clean
args: release --clean --skip-publish --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
# distribution:
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- name: innosetup
run: |
cp ./dist/hyper-v-rest-ps_windows_amd64_v1/hyper-v-rest-ps.exe packaging/hyper-v-rest-ps.exe
cd packaging/
docker build . --security-opt label=disable -t inno:64bit
bash ./iscc.sh 64 innosetup.iss
mv hyper-v-rest-ps.exe hyper-v-rest-ps-portable.exe
- name: upload release
id: create_release
uses: marvinpinto/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
title: Release ${{ github.ref }}
draft: false
prerelease: false
files: |
./packaging/hyper-v-rest-ps-portable.exe
./packaging/Output/hyper-v-rest-ps-setup.exe
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
config.yml
*.gob
conf/config.yml
packaging/Output
packaging/*.exe
*.exe
8 changes: 8 additions & 0 deletions packaging/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM docker.io/amake/innosetup:64bit
USER root
ENV HOME /home/xclient
ENV WINEPREFIX /home/xclient/.wine
#ENV WINEARCH win32
RUN chown -R root /home
WORKDIR /work
ENTRYPOINT ["iscc"]
16 changes: 16 additions & 0 deletions packaging/cleanup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@ECHO OFF
setlocal enabledelayedexpansion
set "ServiceNames[0]=wmi-rest"
set "ServiceNames[1]=hyper-v-rest-wmi"
set "ServiceNames[2]=hyper-v-rest-ps"

for /l %%i in (0, 1, 2) do (
set "ServiceName=!ServiceNames[%%i]!"
sc query !ServiceName! | find "STATE" | find "RUNNING" >nul
if !errorLevel! equ 0 (
sc stop !ServiceName!
)
sc delete !ServiceName!
)

endlocal
55 changes: 55 additions & 0 deletions packaging/innosetup.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[Setup]
AppName=HyperV REST PS
AppVersion=2.1
AppPublisher=Mono Bilisim
AppPublisherURL=https://mono.net.tr
AppSupportURL=https://github.com/monobilisim/hyper-v-rest-ps
AppUpdatesURL=https://github.com/monobilisim/hyper-v-rest-ps
DefaultDirName={code:GetProgramFiles}\hyper-v-rest-ps
UsePreviousAppDir=false
UninstallDisplayIcon={app}\hyper-v-rest-ps.exe
OutputBaseFilename=hyper-v-rest-ps-setup
Compression=lzma
SolidCompression=yes

[Code]
function GetProgramFiles(Param: string): string;
begin
if IsWin64 then Result := ExpandConstant('{commonpf64}')
else Result := ExpandConstant('{commonpf32}')
end;
procedure TaskKill(FileName: String);
var
ResultCode: Integer;
begin
Exec('taskkill.exe', '/f /im ' + '"' + FileName + '"', '', SW_HIDE,
ewWaitUntilTerminated, ResultCode);
end;
[Files]
Source: "hyper-v-rest-ps.exe"; DestDir: "{app}"; BeforeInstall: TaskKill('hyper-v-rest-ps.exe')
Source: "cleanup.bat"; DestDir: "{app}"


[Icons]
;Name: "{group}\HyperV REST PS"; Filename: "{app}\hyper-v-rest-ps.exe"
;Name: "{group}\Uninstall"; Filename: "{uninstallexe}"


[Messages]
SetupAppTitle=HyperV REST PS


[Run]
Filename: "{app}\cleanup.bat"
Filename: "{app}\hyper-v-rest-ps.exe"; Description: "Install Service"; Parameters: --service=install
Filename: "{app}\hyper-v-rest-ps.exe"; Description: "Start Service" ; Parameters: --service=start


[UninstallRun]
Filename: "{app}\cleanup.bat"
Filename: "{app}\hyper-v-rest-ps.exe"; Parameters: --service=stop
Filename: "{app}\hyper-v-rest-ps.exe"; Parameters: --service=uninstall
Filename: "{cmd}"; Parameters: "/C ""taskkill /im hyper-v-rest-ps.exe /f /t"
27 changes: 27 additions & 0 deletions packaging/iscc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

relpaths() {
for arg in "$@"; do printf -- "%s\n" "${arg#$PWD/}"; done
}

bindpaths() {
for arg in $(relpaths "$@"); do
if [ -e "$arg" ] && [[ "$arg" == /* ]]; then
printf -- "-v %s:%s" "$arg" "$arg"
fi
done
}

case $1 in
32)
exec docker run --rm -i --security-opt label=disable -v "$PWD":/work $(bindpaths "$@") -e WINEDEBUG=-all inno:32bit $(relpaths "${@:2}")
;;
64)
exec docker run --rm -i --security-opt label=disable -v "$PWD":/work $(bindpaths "$@") -e WINEDEBUG=-all inno:64bit $(relpaths "${@:2}")
;;
*)
exit 1
;;
esac

chown -R $USER: $PWD/

0 comments on commit 7fb6e0f

Please sign in to comment.