Skip to content

Commit

Permalink
Fix Generate version (#50)
Browse files Browse the repository at this point in the history
* Fix Generate version of windows
  • Loading branch information
Admirepowered authored Jan 31, 2024
1 parent d70d8cf commit 5e35ed2
Showing 1 changed file with 68 additions and 9 deletions.
77 changes: 68 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,23 @@ jobs:
allowUpdates: true
replacesArtifacts: true

Build-kptools-windows:
Build-kptools-windows-msys2:
runs-on: windows-2022
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate version
shell: pwsh
run: |
$MAJOR = (Select-String -Path version -Pattern '#define MAJOR').Line.Split(' ')[2]
$MINOR = (Select-String -Path version -Pattern '#define MINOR').Line.Split(' ')[2]
$PATCH = (Select-String -Path version -Pattern '#define PATCH').Line.Split(' ')[2]
$VERSION = "$MAJOR.$MINOR.$PATCH"
Write-Output "Generated Version: $VERSION"
"VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
Add-Content -Path $env:GITHUB_OUTPUT -Value "VERSION=$VERSION"
- uses: msys2/setup-msys2@v2
with:
update: true
Expand All @@ -264,31 +274,80 @@ jobs:
install: >-
msys/make
msys/gcc
- name: copyfile
- name: Copyfile
shell: pwsh
run: |
D:\a\_temp\msys64\usr\bin\x86_64-pc-msys-gcc.exe --version
ls D:\a\_temp\msys64\usr\bin\
cp .\kernel\include\preset.h .\tools\
cd tools
(Get-Content -Path "Makefile") -replace '\$\(CC\)', " D:\a\_temp\msys64\usr\bin\x86_64-pc-msys-gcc.exe" | Set-Content -Path "Makefile"
(Get-Content -Path "Makefile") -replace '\${CC}', "D:\a\_temp\msys64\usr\bin\x86_64-pc-msys-gcc.exe" | Set-Content -Path "Makefile"
(Get-Content -Path "Makefile") -replace '\$\(CC\)', " x86_64-pc-msys-gcc.exe" | Set-Content -Path "Makefile"
(Get-Content -Path "Makefile") -replace '\${CC}', "x86_64-pc-msys-gcc.exe" | Set-Content -Path "Makefile"
- name: build
shell: cmd
run: |
cd tools
msys2 -c 'make'
- name: Copyfile2
shell: pwsh
run: |
cp .\tools\kptools.exe .\tools\kptools-msys2.exe
7z a kptools-msys2-win .\tools\kptools-msys2.exe D:\a\_temp\msys64\usr\bin\msys-2.0.dll
- name: Release
uses: ncipollo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}
tag: ${{ env.VERSION }}
artifacts: |
.\tools\kptools.exe
kptools-msys2-win.7z
allowUpdates: true
replacesArtifacts: true

Build-kptools-windows-llvm:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
- name: Install mingw32 cross toolchains
run: |
MINGW_LLVM_URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-msvcrt-ubuntu-20.04-x86_64.tar.xz"
mkdir -p $HOME/mingw-llvm
wget $MINGW_LLVM_URL -O $HOME/mingw-llvm/llvm.tar.xz
cd $HOME/mingw-llvm
tar -xvf llvm.tar.xz --strip-components 1
- name: Generate version
id: parse_version
run: |
MAJOR=$(grep '#define MAJOR' version | awk '{print $3}')
MINOR=$(grep '#define MINOR' version | awk '{print $3}')
PATCH=$(grep '#define PATCH' version | awk '{print $3}')
VERSION="$MAJOR.$MINOR.$PATCH"
echo "Generated Version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build kptools
run: |
export PATH="$HOME/mingw-llvm/bin:$PATH"
export ANDROID=1
ABIS="x86_64 i686 aarch64 armv7"
for i in $ABIS; do
make -C kernel hdr TARGET_COMPILE=placeholder
echo "- Compiling kptools-$i-win.exe"
make -C tools CC=$i-w64-mingw32-clang
mv tools/kptools.exe kptools-$i-win.exe
make -C tools clean
done
7za a kptools-llvm-win.zip -tZIP *.exe
- name: Release
uses: ncipollo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}
artifacts: |
kptools-llvm-win.zip
allowUpdates: true
replacesArtifacts: true

Build-kptools-mac:
runs-on: macos-latest
permissions:
Expand Down

0 comments on commit 5e35ed2

Please sign in to comment.