diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 09c742b..ace02e1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -62,7 +62,9 @@ body: description: | 控制台日志。 placeholder: | + ``` 请在此黏贴运行日志。 + ``` - id: system type: input diff --git a/.github/workflows/pkg.yml b/.github/workflows/pkg.yml index c435f9c..4246b3f 100644 --- a/.github/workflows/pkg.yml +++ b/.github/workflows/pkg.yml @@ -16,35 +16,7 @@ on: branches: - main jobs: - pkg_x64: - runs-on: windows-latest - steps: - - name: "Checkout codes" - uses: actions/checkout@v2 - - name: "Use Node.js" - uses: actions/setup-node@v1 - with: - node-version: "16" - - name: "Pkg this" - run: | - npm install - npm run pkg_x64 - - name: "Upload to artifact(win)" - uses: actions/upload-artifact@v2 - with: - name: nlts-win-x64 - path: dist/nlts-win-x64/ - - name: "Upload to artifact(linux)" - uses: actions/upload-artifact@v2 - with: - name: nlts-linux-x64 - path: dist/nlts-linux-x64/ - - name: "Upload to artifact(macos)" - uses: actions/upload-artifact@v2 - with: - name: nlts-macos-x64 - path: dist/nlts-macos-x64/ - pkg_arm64: + build_all: runs-on: ubuntu-latest steps: - name: "Checkout codes" @@ -55,28 +27,18 @@ jobs: node-version: "16" - name: "Pkg this" run: | + sudo apt install zip unzip npm install - npm run pkg_arm64 + npm run build_all - name: "Upload to artifact" uses: actions/upload-artifact@v2 with: - name: nlts-linux-arm64 + name: all_platform path: dist/ - pkg_armv7: - runs-on: ubuntu-latest - steps: - - name: "Checkout codes" - uses: actions/checkout@v2 - - name: "Use Node.js" - uses: actions/setup-node@v1 + - name: "Upload to release draft" + uses: xresloader/upload-to-github-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} with: - node-version: "16" - - name: "Pkg this" - run: | - npm install - npm run pkg_armv7 - - name: "Upload to artifact" - uses: actions/upload-artifact@v2 - with: - name: nlts-linux-armv7 - path: dist/ + file: "dist/*.zip" + delete_file: "dist/*.zip" diff --git a/package.json b/package.json index 201b74c..b7f3aef 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,7 @@ "clear": "node main.js clear", "check": "node main.js check", "update": "node main.js update", - "pkg_x64": "PowerShell .\\script\\pkg\\pkg.ps1", - "pkg_arm64": "npx pkg -t node16-linux-arm64 -o dist/lottery main.js && cp my_config.example.js dist/my_config.js && cp env.example.js dist/env.js", - "pkg_armv7": "npx pkg -t node16-linuxstatic-armv7 -o dist/lottery main.js && cp my_config.example.js dist/my_config.js && cp env.example.js dist/env.js" + "build_all": "bash script/build/pkg.sh" }, "files": [ "lib", @@ -24,9 +22,12 @@ "bin": "main.js", "pkg": { "targets": [ - "linux-x64", - "win-x64", - "macos-x64" + "node12-win-x64", + "node16-win-x64", + "node16-linux-x64", + "node16-macos-x64", + "node16-linuxstatic-arm64", + "node16-linuxstatic-armv7" ], "outputPath": "dist" }, diff --git a/script/build/pkg.sh b/script/build/pkg.sh new file mode 100755 index 0000000..3e8a9dd --- /dev/null +++ b/script/build/pkg.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +ROOT=$PWD +README="README.md" +TEMPLATE_CONFIG_FILE="my_config.example.js" +TEMPLATE_ENV_FILE="env.example.js" +CONFIG_FILE="my_config.js" +ENV_FILE="env.js" +TARGET_DIR="./dist" +BIN_NAME="lottery" + +create_win_bat() { + echo "@echo off && lottery $1 && pause" +} + +if [ -d "$TARGET_DIR" ]; then + rm -rf "$TARGET_DIR" +fi + +npx pkg . + +# Searching in the current directory +for file in "$TARGET_DIR/"*; do + TMPDIR="${file%.exe}" + TMPDIR_NAME="${TMPDIR##*/}" + REMANE_FILE="$TARGET_DIR/$BIN_NAME" + mv $file $REMANE_FILE + mkdir -p "$TMPDIR/" + mv $REMANE_FILE "$TMPDIR/" + cp $README "$TMPDIR/" + cp $TEMPLATE_CONFIG_FILE "$TMPDIR/$CONFIG_FILE" + cp $TEMPLATE_ENV_FILE "$TMPDIR/$ENV_FILE" + if [ "$(echo $file | grep '.exe')" ]; then + BATS=("start" "check" "clear" "update") + for item in "${BATS[@]}"; do + create_win_bat "${item}" >"$TMPDIR/$item.bat" + done + else + cat >"$TMPDIR/update.sh" <<-EOF + #!/bin/bash + ./lottery update + if [[ -r "latest_version.zip" ]]; then + unzip latest_version.zip + rm latest_version.zip + chmod u+x lottery + fi + EOF + fi + cd $TMPDIR + zip -r "$TMPDIR_NAME.zip" . + mv "$TMPDIR_NAME.zip" ../ + cd $ROOT +done diff --git a/script/docker/init.sh b/script/docker/init.sh index 7ccc958..b62de36 100755 --- a/script/docker/init.sh +++ b/script/docker/init.sh @@ -129,7 +129,7 @@ echo "create remove_all.sh" cat >remove_all.sh <