diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ca3f68d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + release: + types: [published] + push: + tags: + - v* + branches: [ master ] + # pull_request: + # branches: [ master ] + # # Allows you to run this workflow manually from the Actions tab + # workflow_dispatch: + +jobs: + build: + + name: Build + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - name: Build + run: | + pwd + ls -l + chmod 777 docker/entrypoint + chmod 777 tools/* + export ACTION_MODE=true + tools/setup-wechat-devtools-node + + - name: Delete unused file + run: | + sudo rm -rf cache tmp + + - name: Release + uses: fnkr/github-action-ghr@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + GHR_COMPRESS: xz + GHR_PATH: /github/workspace + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/conf/node.json b/conf/node.json index 32d5aa2..ca058b8 100644 --- a/conf/node.json +++ b/conf/node.json @@ -1,5 +1,6 @@ { "description": "此处版本应与nwjs使用的node版本一致", "version": "14.5.0", - "url": "https://npm.taobao.org/mirrors/node/v${version}/node-v${version}-linux-x64.tar.gz" + "url": "https://npm.taobao.org/mirrors/node/v${version}/node-v${version}-linux-x64.tar.gz", + "url-global": "https://nodejs.org/download/release/v${version}/node-v${version}-linux-x64.tar.gz" } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0138de6..ed03d6e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,9 @@ version: "3" services: - web: + wechat_devtools: image: node:16.13.1 volumes: - .:/workspace + environment: + - ACTION=${ACTION_MODE:-false} entrypoint: /workspace/docker/entrypoint \ No newline at end of file diff --git a/docker/entrypoint b/docker/entrypoint index 764e817..96573ac 100644 --- a/docker/entrypoint +++ b/docker/entrypoint @@ -36,12 +36,10 @@ echo "\ apt-get clean; # 清空缓存 apt-get update; # 更新 -apt-get install -y libx11-dev libxkbfile-dev +apt-get install -y libx11-dev libxkbfile-dev p7zip-full -hash node-gyp 2>/dev/null || { - echo >&2 "I require node-gyp but it's not installed. Installing."; - npm install -g node-gyp -} +npm install -g node-gyp +node-gyp install node-gyp list @@ -55,10 +53,5 @@ node-gyp list # end test cd /workspace -hash 7z 2>/dev/null || { - echo >&2 "I require 7z but it's not installed. Installing."; - apt-get update - apt-get install p7zip-full -y -} -export https_proxy="http://192.168.249.236:7890" +# export https_proxy="http://192.168.249.236:7890" exec ./tools/setup-wechat-devtools-bash diff --git a/test/env b/test/env new file mode 100644 index 0000000..49b6b64 --- /dev/null +++ b/test/env @@ -0,0 +1,2 @@ +#!/usr/bin/env node +console.log(process.env['action']==='true') \ No newline at end of file diff --git a/tools/fix-package-name-node b/tools/fix-package-name-node index 4545834..cdfb331 100644 --- a/tools/fix-package-name-node +++ b/tools/fix-package-name-node @@ -5,16 +5,18 @@ const { spawn } = require("child_process"); const parseFile = function (path) { + console.log("fix start") if (!fs.existsSync(path)) { return; } - + console.log("content") let content = JSON.parse(fs.readFileSync(path, "utf8")); content.name = "wechat_devtools"; // 开启调试,更新参数 content['chromium-args'] = content['chromium-args'].replace('--disable-devtools', '').replace('--ignore-gpu-blacklist', '--ignore-gpu-blocklist') + console.log("arite") fs.writeFileSync(path, JSON.stringify(content, null, 4)); }; diff --git a/tools/update-node-node b/tools/update-node-node index 1861f2f..96403a2 100644 --- a/tools/update-node-node +++ b/tools/update-node-node @@ -13,8 +13,8 @@ const download = function () { fs.mkdirSync(path.resolve(__dirname, "../cache")); } catch (error) {} - let url = nodeConfig.url - .replace("${version}", nodeConfig.version) + let url = process.env['ACTION'] === 'true'?nodeConfig["url-global"]:nodeConfig.url + url = url.replace("${version}", nodeConfig.version) .replace("${version}", nodeConfig.version); let localPath = path.resolve(