diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index fd6f4c6f..e8a898ba 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -1,6 +1,11 @@ name: release Linux on: + workflow_dispatch: + inputs: + release_tag: + required: false + type: string push: branches: [ "master" ] pull_request: @@ -21,14 +26,40 @@ jobs: - name: Build run: | cd v2rayN - chmod 755 build-linux.sh - ./build-linux.sh + OutputPath='./bin/v2rayN' + OutputPath64="${OutputPath}/linux-x64" + OutputPathArm64="${OutputPath}/linux-arm64" + dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o $OutputPath64 + dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-arm64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o $OutputPathArm64 - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: v2rayN-linux path: | - ./v2rayN/v2rayN-linux.zip + ./v2rayN/bin/v2rayN - \ No newline at end of file + - name: Package debian + if: github.event.inputs.release_tag != '' + run: | + cd v2rayN + chmod 755 package-debian.sh + ./package-debian.sh ${{ github.event.inputs.release_tag }} x64 + ./package-debian.sh ${{ github.event.inputs.release_tag }} arm64 + + - name: Upload Package artifacts + uses: actions/upload-artifact@v4 + if: github.event.inputs.release_tag != '' + with: + name: v2rayN-linux-Package + path: | + ${{ github.workspace }}/v2rayN/v2rayN*.deb + + - name: Upload to release + uses: svenstaro/upload-release-action@v2 + if: github.event.inputs.release_tag != '' + with: + file: ${{ github.workspace }}/v2rayN/v2rayN*.deb + tag: ${{ github.event.inputs.release_tag }} + file_glob: true + prerelease: true \ No newline at end of file diff --git a/v2rayN/build-linux.sh b/v2rayN/build-linux.sh deleted file mode 100644 index 4f5141c3..00000000 --- a/v2rayN/build-linux.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -echo 'Building Linux' - -OutputPath='./bin/v2rayN' -OutputPath64="${OutputPath}/linux-x64" -OutputPathArm64="${OutputPath}/linux-arm64" - -dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o $OutputPath64 -dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-arm64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o $OutputPathArm64 - -rm -rf "$OutputPath64/*.pdb" -rm -rf "$OutputPathArm64/*.pdb" - -echo 'Build done' - -7z a v2rayN-linux.zip $OutputPath -exit 0 diff --git a/v2rayN/package-debian.sh b/v2rayN/package-debian.sh new file mode 100644 index 00000000..c1ad3a12 --- /dev/null +++ b/v2rayN/package-debian.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +version="$1" +arch="$2" + +OutputPath="v2rayN-linux-${arch}" +mkdir -p "${OutputPath}/DEBIAN" +mkdir -p "${OutputPath}/opt" +cp -r "./bin/v2rayN/linux-${arch}" "${OutputPath}/opt" +mv "${OutputPath}/opt/linux-${arch}" "${OutputPath}/opt/v2rayN" + + +if [ $arch = "x64" ]; then + Arch2="amd64" +else + Arch2="arm64" +fi +echo $Arch2 + +# basic +cat >"${OutputPath}/DEBIAN/control" <<-EOF +Package: v2rayN +Version: $version +Architecture: $Arch2 +Maintainer: https://github.com/2dust/v2rayN +Description: A GUI client for Windows and Linux, support Xray core and sing-box-core and others +EOF + +cat >"${OutputPath}/DEBIAN/postinst" <<-EOF +if [ ! -s /usr/share/applications/v2rayN.desktop ]; then + cat >/usr/share/applications/v2rayN.desktop<<-END +[Desktop Entry] +Name=v2rayN +Comment=A GUI client for Windows and Linux, support Xray core and sing-box-core and others +Exec=/opt/v2rayN/v2rayN +Icon=/opt/v2rayN/v2rayN.png +Terminal=false +Type=Application +Categories=Network;Application; +END +fi + +update-desktop-database +EOF + +sudo chmod 0755 "${OutputPath}/DEBIAN/postinst" +sudo chmod 0755 "${OutputPath}/opt/v2rayN/v2rayN" + +# desktop && PATH + +sudo dpkg-deb -Zxz --build $OutputPath \ No newline at end of file