Skip to content

Commit

Permalink
Upload the build output of pull requests (#122)
Browse files Browse the repository at this point in the history
* Upload the build output of pull requests

* Fix incorrect commit sha
  • Loading branch information
koho authored Feb 17, 2024
1 parent 26186ca commit e4822ac
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,32 @@ jobs:
run: |
for /f "usebackq delims=" %%i in (`vswhere.exe -latest -property installationPath`) do echo %%i\VC\Auxiliary\Build>>%GITHUB_PATH%
- name: Add commit hash to version number
shell: powershell
if: github.event_name == 'pull_request'
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
$versionFile = ".\pkg\version\version.go"
$rev = [UInt16]("0x" + $env:HEAD_SHA.Substring(0, 4))
$version = (findstr /r "Number.*=.*[0-9.]*" $versionFile | Select-Object -First 1 | ConvertFrom-StringData).Get_Item("Number")
$newVersion = $version.Substring(0, $version.Length - 1) + ".$rev" + '"'
(Get-Content $versionFile).Replace($version, $newVersion) | Set-Content $versionFile
- name: Build
shell: cmd
run: build.bat

- name: Upload
uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: build
path: |
bin/*.exe
bin/*.zip
retention-days: 5

test:
name: Go
runs-on: windows-latest
Expand Down
6 changes: 3 additions & 3 deletions iconize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package main

import (
"flag"
"log"
"os"
"os/exec"
"path/filepath"
Expand All @@ -25,7 +24,8 @@ func init() {
func main() {
files, err := os.ReadDir(dir)
if err != nil {
log.Fatal(err)
println(err.Error())
os.Exit(1)
}
for _, f := range files {
if f.IsDir() {
Expand All @@ -40,7 +40,7 @@ func main() {
res, err := exec.Command(".deps/convert.exe", "-background", "none", path,
"-define", "icon:auto-resize=256,192,128,96,64,48,40,32,24,20,16", "-compress", "zip", output).CombinedOutput()
if err != nil {
log.Fatalf("Failed to convert icon: %s", string(res))
println(err.Error(), string(res))
}
}
}
2 changes: 1 addition & 1 deletion installer/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if "%WIX%"=="" (
"%WindowsSdkVerBinPath%x86\MsiTran" -g %MSI_FILE% !WIX_LANG_MSI! %PLAT_DIR%\!LANG_CODE! || goto :error
"%WindowsSdkVerBinPath%x86\MsiDb" -d %MSI_FILE% -r %PLAT_DIR%\!LANG_CODE! || goto :error
)
windres -DARCH=%ARCH% -DVERSION_ARRAY=%VERSION:.=,%,0 -DVERSION_STR=%VERSION% -DMSI_FILE=%MSI_FILE:\=\\% -i setup\resource.rc -o %PLAT_DIR%\rsrc.o -O coff -c 65001 -F !RES%ARCH%! || goto :error
windres -DARCH=%ARCH% -DVERSION_ARRAY=%VERSION:.=,% -DVERSION_STR=%VERSION% -DMSI_FILE=%MSI_FILE:\=\\% -i setup\resource.rc -o %PLAT_DIR%\rsrc.o -O coff -c 65001 -F !RES%ARCH%! || goto :error
cl /Fe..\bin\frpmgr-%VERSION%-setup-%ARCH%.exe /Fo%PLAT_DIR%\setup.obj /utf-8 setup\setup.c /link /subsystem:windows %PLAT_DIR%\rsrc.o shlwapi.lib msi.lib user32.lib advapi32.lib
goto :eof

Expand Down
9 changes: 5 additions & 4 deletions resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package main

import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
Expand All @@ -15,22 +15,23 @@ import (
)

var (
versionArray = strings.ReplaceAll(version.Number, ".", ",") + ",0"
versionArray = strings.ReplaceAll(version.Number, ".", ",")
archMap = map[string]string{"amd64": "pe-x86-64", "386": "pe-i386"}
)

func main() {
rcFiles, err := filepath.Glob("cmd/*/*.rc")
if err != nil {
log.Fatal(err)
println(err.Error())
os.Exit(1)
}
for _, rc := range rcFiles {
for goArch, resArch := range archMap {
output := strings.TrimSuffix(rc, filepath.Ext(rc)) + fmt.Sprintf("_windows_%s.syso", goArch)
res, err := exec.Command("windres", "-DVERSION_ARRAY="+versionArray, "-DVERSION_STR="+version.Number,
"-i", rc, "-o", output, "-O", "coff", "-c", "65001", "-F", resArch).CombinedOutput()
if err != nil {
log.Fatalf("Failed to compile resource: %s", string(res))
println(err.Error(), string(res))
}
}
}
Expand Down

0 comments on commit e4822ac

Please sign in to comment.