diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f41875..69b9a05 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ # 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 +name: Build Packages on: release: @@ -9,7 +9,7 @@ on: push: tags: - v* - branches: [ master, actions-dev] + branches: [ master, aur] pull_request: branches: [ master ] # # Allows you to run this workflow manually from the Actions tab @@ -17,7 +17,7 @@ on: jobs: build: - name: Build + name: Build tar.gz AppImage runs-on: ubuntu-latest strategy: @@ -43,7 +43,8 @@ jobs: npm install node-gyp nw-gyp npm -g node-gyp install - - id: Tag + - name: Generate TAG + id: Tag run: | tag='continuous' name='Continuous Build' @@ -54,10 +55,13 @@ jobs: echo "tag result: $tag - $name" echo "::set-output name=tag::$tag" echo "::set-output name=name::$name" - + - name: Build run: | # docker-compose up + export ACTION=true + # tar.gz AppImage + ls -l tools/setup-wechat-devtools-bash sudo chmod -R 755 package.nw bash tools/build-release.sh ${{ steps.tag.outputs.tag }} ${{ matrix.ARCH }} @@ -78,15 +82,187 @@ jobs: run: | ls -l + - name: Upload artifact + uses: actions/upload-artifact@v2.3.1 + with: + # Artifact name + name: wechat-devtools-${{ matrix.ARCH }}.build + path: tmp/build + + build-deb: + name: Build Deb Package + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.x] + ARCH: ['x86_64'] + # 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: Prepare + run: | + pwd + ls -l + export ACTION_MODE=true + sudo apt-get install -y libx11-dev libxkbfile-dev p7zip-full python2 python3 libkrb5-dev gcc openssl libssh2-1-dev g++ make + npm install node-gyp nw-gyp npm -g + node-gyp install + # https://docs.makedeb.org/home/installing/apt-repository/ + wget -qO - 'https://proget.hunterwittenborn.com/debian-feeds/makedeb.pub' | \ + gpg --dearmor | \ + sudo tee /usr/share/keyrings/makedeb-archive-keyring.gpg &> /dev/null + echo 'deb [signed-by=/usr/share/keyrings/makedeb-archive-keyring.gpg arch=all] https://proget.hunterwittenborn.com/ makedeb main' | \ + sudo tee /etc/apt/sources.list.d/makedeb.list + sudo apt update + sudo apt-get install -y makedeb gconf2 + + - name: Generate TAG + id: Tag + run: | + tag='continuous' + name='Continuous Build' + if [ 'true' == ${{ startsWith(github.ref, 'refs/tags/') }} ];then + tag='${{ github.ref_name }}' + name='${{ github.ref_name }}' + fi + echo "tag result: $tag - $name" + echo "::set-output name=tag::$tag" + echo "::set-output name=name::$name" + + - name: Build Deb Package + run: | + tools/build-aur.sh deb + # deb + cd tmp/AUR + makedeb + cd ../ + # ./tmp + ls -l AUR + mkdir -p build + mv AUR/*.deb build + rm -rf AUR/pkg AUR/src + ls -l build + + - name: Upload artifact + uses: actions/upload-artifact@v2.3.1 + with: + # Artifact name + name: wechat-devtools-${{ matrix.ARCH }}.build + path: tmp/build + + build-arch: + name: Build ArchLinux Package + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + matrix: + node-version: [16.x] + ARCH: ['x86_64'] + # 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: Prepare + run: | + npm install node-gyp nw-gyp npm -g + node-gyp install + cat /etc/passwd + + - name: Generate TAG + id: Tag + run: | + tag='continuous' + name='Continuous Build' + if [ 'true' == ${{ startsWith(github.ref, 'refs/tags/') }} ];then + tag='${{ github.ref_name }}' + name='${{ github.ref_name }}' + fi + echo "tag result: $tag - $name" + echo "::set-output name=tag::$tag" + echo "::set-output name=name::$name" + + - name: Build ArchLinux Package + uses: countstarlight/arch-makepkg-action@master + with: + repos: > + archlinuxcn=https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch + before: "tools/build-aur.sh && sudo pacman -S --noconfirm archlinuxcn-keyring" + packages: > + gconf + p7zip + libxkbfile + python2 + openssl + gcc + make + libssh2 + krb5 + scripts: "cd tmp/AUR && makepkg && ls -l && cd ../../" + + - name: Fix Permissions + run: | + sudo chmod -R 0777 tmp + mkdir -p tmp/build + mv tmp/AUR/*.pkg.* tmp/build + cd tmp/build + for file in `ls *.pkg.*`;do mv $file `echo $file|sed 's/:/-/g'`;done; + ls -l + + - name: Upload artifact + uses: actions/upload-artifact@v2.3.1 + with: + # Artifact name + name: wechat-devtools-${{ matrix.ARCH }}.build + path: tmp/build + + upload: + name: Create release and upload artifacts + needs: + - build + - build-deb + - build-arch + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v2 + - name: Inspect directory after downloading artifacts + run: ls -alFR + + - name: Generate TAG + id: Tag + run: | + tag='continuous' + name='Continuous Build' + if [ 'true' == ${{ startsWith(github.ref, 'refs/tags/') }} ];then + tag='${{ github.ref_name }}' + name='${{ github.ref_name }}' + fi + echo "tag result: $tag - $name" + echo "::set-output name=tag::$tag" + echo "::set-output name=name::$name" + - name: Create release and upload artifacts if: startsWith(github.ref, 'refs/heads/') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cd tmp/build wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage chmod +x pyuploadtool-x86_64.AppImage - ./pyuploadtool-x86_64.AppImage WeChat*.AppImage *.tar.gz + ./pyuploadtool-x86_64.AppImage **/WeChat*.AppImage **/*.tar.gz **/*.deb **/*.pkg.* - name: Release uses: softprops/action-gh-release@v1 @@ -97,5 +273,7 @@ jobs: name: ${{ steps.tag.outputs.name }} tag_name: ${{ steps.tag.outputs.tag }} files: | - tmp/build/*.tar.gz - tmp/build/*.AppImage \ No newline at end of file + **/WeChat*.AppImage + **/*.tar.gz + **/*.deb + **/*.pkg.* \ No newline at end of file diff --git a/res/aur/PKGBUILD b/res/aur/PKGBUILD new file mode 100755 index 0000000..78647a2 --- /dev/null +++ b/res/aur/PKGBUILD @@ -0,0 +1,119 @@ +# Maintainer: msojocs +# Contributor: ccat3z +# Contributor: bruceutut + +# 方法参考 +# https://github.com/jiyeme/wechat-devtools +# https://github.com/dragonation/wechat-devtools +# https://github.com/cytle/wechat_web_devtools + +_wechat_devtools_ver="1.05.2201240" +_wechat_devtools_url="https://dldir1.qq.com/WechatWebDev/release/p-ae42ee2cde4d42ee80ac60b35f183a99/wechat_devtools_1.05.2201240_x64.exe" +_wechat_devtools_md5="85552bae33e98eb186c5068419efce03" + +_wechat_devtools_exe="wechat_devtools_${_wechat_devtools_ver}_x64.exe" +_nwjs_ver="0.53.1" +_install_dir="/opt/wechat-devtools" +_node_version="16.1.0" + +pkgname=wechat-devtools +pkgver="${_wechat_devtools_ver}" # 主版本号 +pkgrel=15 # 次版本号release +epoch=2 # 大版本迭代强制更新(维护者变更,尽量不用) +pkgdesc="WeChat Devtools For Linux. " +arch=("x86_64") +url="https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html" +license=('unknown') +depends=('gconf' 'libxkbfile') +makedepends=('p7zip' 'python2' 'openssl' 'gcc' 'make' 'libssh2' 'krb5') +# compiler 用于可视化,以及编译 +source=("nwjs-v${_nwjs_ver}.tar.gz::https://npm.taobao.org/mirrors/nwjs/v${_nwjs_ver}/nwjs-sdk-v${_nwjs_ver}-linux-x64.tar.gz" + "${_wechat_devtools_exe}::${_wechat_devtools_url}" + "node-v${_node_version}.tar.gz::https://npm.taobao.org/mirrors/node/v${_node_version}/node-v${_node_version}-linux-x64.tar.gz" + "compiler.tar.gz::https://download.fastgit.org/msojocs/wechat-devtools-linux/releases/download/v0.19/compiler.tar.gz" + "wechat-devtools.desktop" + "logo.svg" + "fix-cli.sh" + "fix-menu.sh" + "fix-core.sh" + "rebuild-node-modules.sh" + "fix-package-name.js" + "wxvpkg_pack.js" + "wxvpkg_unpack.js" + "fix-other.sh") +md5sums=(b6f49803c51d0abacca2d1e566c7fe19 # nwjs + "${_wechat_devtools_md5}" + 2280bfbbf29981fd5adce334f40146ff # nodejs + a9e061c97afbbc295b5664a2d8065492 # compiler + 1abd6b4ebbbb918f601a6c5dbad55a05 # desktop + 0f4353664123320280ea4d6bb295dce2 # svg + "SKIP" + "SKIP" + "SKIP" + "SKIP" + "SKIP" + "SKIP" + "SKIP" + "SKIP") +options=('!strip') + +prepare() { + 7z x -owechat_devtools ${_wechat_devtools_exe} code/package.nw + mv wechat_devtools/code/package.nw package.nw + rm -rf wechat_devtools + ls | grep node-*linux* | xargs -I{} mv {} node + ls | grep nwjs-*linux* | xargs -I{} mv {} nwjs + + mkdir tools + for file in *.js *.sh; do + mv $file tools; + done +} + +_log() { + echo -e "\e[1;34m$@\e[0m" +} + +build() { + # prepare node + _log "prepare node v${_node_version}" + export PATH="$srcdir/node/bin:$PATH" + + # prepare nw-gyp + _log "prepare nw-gyp" + npm uninstall node-gyp -g + npm install nw-gyp node-gyp -g + + # node bin + _log "copy node exectuable" + cp "$(which node)" "${srcdir}/node.${_node_version}" + + # run fix scripts + export NW_PACKAGE_DIR="${srcdir}/package.nw" + export NW_VERSION=$_nwjs_ver + export srcdir=$srcdir + export NO_WINE=true + + for script in fix-package-name.js fix-cli.sh fix-other.sh fix-menu.sh fix-core.sh rebuild-node-modules.sh; do + _log "run ${script}" + "${srcdir}/tools/${script}" + done + + # cleanup + _log "done" +} + +package() { + mkdir -p "${pkgdir}${_install_dir}" + cd "${pkgdir}${_install_dir}" + + cp -r "${srcdir}/nwjs/"* ./ + cp -r "${srcdir}/package.nw" ./package.nw + find ./package.nw -type d | xargs -I {} chmod -R a+rx {} + + cp ${srcdir}/node.${_node_version} node + ln -s node node.exe + + install -Dm644 "${srcdir}/wechat-devtools.desktop" "${pkgdir}/usr/share/applications/wechat-devtools.desktop" + install -Dm644 "${srcdir}/logo.svg" "${pkgdir}/usr/share/icons/hicolor/scalable/apps/wechat-devtools.svg" +} diff --git a/res/aur/logo.svg b/res/aur/logo.svg new file mode 100755 index 0000000..1dc031c --- /dev/null +++ b/res/aur/logo.svg @@ -0,0 +1,123 @@ + + + + diff --git a/res/aur/wechat-devtools.desktop b/res/aur/wechat-devtools.desktop new file mode 100755 index 0000000..03ddbb0 --- /dev/null +++ b/res/aur/wechat-devtools.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=WeChat Devtools +Name[zh_CN]=微信web开发者工具 +Comment=The development tools for wechat web develop +Categories=Development;WebDevelopment;IDE; +Exec=env APPDATA=~/.config/wechat_devtools USERPROFILE=~ bash -c ' clean_cache(){ echo "清理缓存"; rm -rf "$APPDATA/WeappCache"; rm -rf "$APPDATA/WeappVendor";}; if [[ -f "$APPDATA/.build_time" ]];then diff "$APPDATA/.build_time" "/opt/wechat-devtools/package.nw/.build_time" >/dev/null; if [ ! "$?" == "0" ];then \cp -f "/opt/wechat-devtools/package.nw/.build_time" "$APPDATA/.build_time";clean_cache; fi; else \cp -f "/opt/wechat-devtools/package.nw/.build_time" "$APPDATA/.build_time"; clean_cache; fi; /opt/wechat-devtools/nw --load-extension=~/.config/wechat_devtools/WeappPlugin --custom-devtools-frontend=file:///opt/wechat-devtools/package.nw/js/ideplugin/inspector %U' +Path=/opt/wechat-devtools +Icon=wechat-devtools +Type=Application +Terminal=false +StartupWMClass=nwjs_mbeenbnhnmdhkbicabncjghgnikfbgjh +MimeType=x-scheme-handler/wechatide \ No newline at end of file diff --git a/tools/build-aur.sh b/tools/build-aur.sh new file mode 100755 index 0000000..5cdb043 --- /dev/null +++ b/tools/build-aur.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +root_dir=$(cd `dirname $0`/.. && pwd -P) +tmp_dir="$root_dir/tmp" +build_dir="$root_dir/tmp/AUR" + +rm -rf $build_dir +mkdir -p $build_dir +cp "$root_dir/tools"/*.sh "$build_dir" +cp "$root_dir/tools"/*.js "$build_dir" +cp "$root_dir/res/aur"/* "$build_dir" +sed -i 's/download.fastgit.org/github.com/' "$build_dir/PKGBUILD" + +if [[ $1 == 'deb' ]];then + sed -i 's/libssh2/libssh2-1-dev/' "$build_dir/PKGBUILD" + sed -i 's/libxkbfile/libxkbfile-dev/' "$build_dir/PKGBUILD" + sed -i 's/gconf/gconf2/' "$build_dir/PKGBUILD" + sed -i 's/krb5/libkrb5-dev/' "$build_dir/PKGBUILD" +fi +cd $build_dir +# makepkg \ No newline at end of file diff --git a/tools/update-node-node b/tools/update-node-node index 3c5ef2e..d3d8af7 100755 --- a/tools/update-node-node +++ b/tools/update-node-node @@ -10,7 +10,9 @@ const download = function () { return new Promise((resolve, reject) => { try { fs.mkdirSync(path.resolve(__dirname, "../cache")); - } catch (error) {} + } catch (error) { + console.error(error) + } let url = process.env['ACTION'] === 'true'?nodeConfig["url-global"]:nodeConfig.url url = url.replace("${version}", nodeConfig.version)