From 7fb6e0f27926a7024467eb64ed043e61b185a518 Mon Sep 17 00:00:00 2001 From: mt190502 Date: Thu, 14 Sep 2023 21:41:06 +0300 Subject: [PATCH] updated releaser --- .github/workflows/release.yaml | 48 +++++++++++++++++++++-------- .gitignore | 5 ++-- packaging/Dockerfile | 8 +++++ packaging/cleanup.bat | 16 ++++++++++ packaging/innosetup.iss | 55 ++++++++++++++++++++++++++++++++++ packaging/iscc.sh | 27 +++++++++++++++++ 6 files changed, 145 insertions(+), 14 deletions(-) create mode 100644 packaging/Dockerfile create mode 100644 packaging/cleanup.bat create mode 100755 packaging/innosetup.iss create mode 100644 packaging/iscc.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 41d2986..8975a7b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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/action-automatic-releases@v1.2.1 + 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 diff --git a/.gitignore b/.gitignore index be29e43..5aabc08 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ -config.yml -*.gob +conf/config.yml +packaging/Output +packaging/*.exe *.exe diff --git a/packaging/Dockerfile b/packaging/Dockerfile new file mode 100644 index 0000000..33cb632 --- /dev/null +++ b/packaging/Dockerfile @@ -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"] diff --git a/packaging/cleanup.bat b/packaging/cleanup.bat new file mode 100644 index 0000000..43e22fe --- /dev/null +++ b/packaging/cleanup.bat @@ -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 diff --git a/packaging/innosetup.iss b/packaging/innosetup.iss new file mode 100755 index 0000000..8d9b274 --- /dev/null +++ b/packaging/innosetup.iss @@ -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" diff --git a/packaging/iscc.sh b/packaging/iscc.sh new file mode 100644 index 0000000..4872ead --- /dev/null +++ b/packaging/iscc.sh @@ -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/