From fff1ea20a6aa01c3ce282ba253abb074c5b9cca3 Mon Sep 17 00:00:00 2001 From: msojocs Date: Tue, 15 Feb 2022 12:52:59 +0800 Subject: [PATCH] appimage: init --- .github/workflows/release.yml | 134 ++++++++++++++++++++++--------- docker/entrypoint | 0 res/appimage.desktop | 12 +++ tools/appimage.sh | 28 +++++++ tools/fix-wcc-wcsc | 0 tools/setup-wechat-devtools-bash | 0 6 files changed, 135 insertions(+), 39 deletions(-) mode change 100644 => 100755 docker/entrypoint create mode 100644 res/appimage.desktop create mode 100644 tools/appimage.sh mode change 100644 => 100755 tools/fix-wcc-wcsc mode change 100644 => 100755 tools/setup-wechat-devtools-bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index afad031..003aa61 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,12 +4,8 @@ name: Node.js CI on: - release: - types: [published] push: - tags: - - v* - branches: [ master, actions ] + branches: [ master, appimage ] pull_request: branches: [ master ] # # Allows you to run this workflow manually from the Actions tab @@ -17,51 +13,111 @@ on: jobs: build: - name: Build 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' + - 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 + - name: Prepare + run: | + pwd + ls -l + export ACTION_MODE=true + npm uninstall node-gyp -g + npm install node-gyp nw-gyp npm -g + + - 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 + run: docker-compose up + + - name: Build AppImage + run: | + sudo chmod -R 777 tmp package.nw node + bash tools/appimage.sh + wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" + chmod a+x appimagetool-x86_64.AppImage + ./appimagetool-x86_64.AppImage ./tmp/AppDir + env: + name: 'release-${{ github.ref_name }}' + ARCH: '${{ matrix.ARCH }}' + + - name: Delete unused file + run: | + ls -l + sudo rm -rf cache tmp appimagetool-x86_64.AppImage + mkdir ${{ env. name }} + sudo find -maxdepth 1 -not -name ${{ env.name }} -not -name . -exec mv {} ${{ env.name }} \; + sudo cp -r "${{ env.name }}/package.nw/node_modules/nodegit" nodegit + sudo cp -r "${{ env.name }}/compiler" compiler + sudo mv ${{ env.name }}/WeChat*.AppImage . + ls -l + cd "${{ env.name }}" + env: + name: 'release-${{ github.ref_name }}' + + - name: Compress + run: | ls -l - chmod 777 docker/entrypoint - chmod 777 tools/* - export ACTION_MODE=true - npm uninstall node-gyp -g - npm install node-gyp nw-gyp npm -g + tar -zvcf ${{ env.name }}.tar.gz ${{ env.name }} + tar -zvcf compiler.tar.gz compiler + tar -zvcf nodegit.tar.gz nodegit + sudo rm -rf ${{ env.name }} compiler nodegit + ls -l + env: + name: 'release-${{ github.ref_name }}' - - name: Build - run: docker-compose up + # - name: Release + # uses: fnkr/github-action-ghr@v1 + # if: startsWith(github.ref, 'refs/tags/') + # env: + # GHR_COMPRESS: xz + # GHR_PATH: . + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Delete unused file - run: | - sudo rm -rf cache tmp - mkdir ${{ env. name }} - sudo find -maxdepth 1 -not -name ${{ env.name }} -not -name . -exec mv {} ${{ env.name }} \; - sudo cp -r "${{ env.name }}/package.nw/node_modules/nodegit" nodegit - sudo cp -r "${{ env.name }}/compiler" compiler - ls -ls - env: - name: 'release-${{ github.ref_name }}' + - name: Release + uses: softprops/action-gh-release@v1 + with: + # note you'll typically need to create a personal access token + # with permissions to create releases in the other repo + name: ${{ steps.tag.outputs.name }} + tag_name: ${{ steps.tag.outputs.tag }} + files: | + ${{ env.name }}.tar.gz + compiler.tar.gz + nodegit.tar.gz + *.AppImage + env: + name: 'release-${{ github.ref_name }}' - - name: Release - uses: fnkr/github-action-ghr@v1 - if: startsWith(github.ref, 'refs/tags/') - env: - GHR_COMPRESS: xz - GHR_PATH: . - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Create release and upload artifacts + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # GITHUB_CONTINUOUS_RELEASE_TAG: ${{ steps.tag.outputs.tag }} + # GITHUB_CONTINUOUS_RELEASE_NAME: ${{ steps.tag.outputs.name }} + # run: | + # wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage + # chmod +x pyuploadtool-x86_64.AppImage + # ./pyuploadtool-x86_64.AppImage **/*.AppImage* diff --git a/docker/entrypoint b/docker/entrypoint old mode 100644 new mode 100755 diff --git a/res/appimage.desktop b/res/appimage.desktop new file mode 100644 index 0000000..38b523d --- /dev/null +++ b/res/appimage.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=WeChat Dev Tools +Name[zh_CN]=微信开发者工具 +Comment=The development tools for wechat projects +Comment[zh_CN]=提供微信开发相关项目的开发IDE支持 +Categories=Development;WebDevelopment;IDE; +Exec=bin/wechat-devtools +Icon=wechat-devtools +Type=Application +Terminal=false +StartupWMClass=wechat_devtools +Actions= \ No newline at end of file diff --git a/tools/appimage.sh b/tools/appimage.sh new file mode 100644 index 0000000..87c2fc9 --- /dev/null +++ b/tools/appimage.sh @@ -0,0 +1,28 @@ +#!/bin/bash +export ARCH=x86_64 + +root_dir=$(cd `dirname $0`/.. && pwd -P) +tmp_dir="$root_dir/tmp" +app_dir="$root_dir/tmp/AppDir" + +# Remove any previous build +rm -rf $app_dir +# Make usr and icons dirs +mkdir -p $app_dir/bin +mkdir -p $app_dir/usr/{src,bin} +mkdir -p $app_dir/usr/share/{metainfo,icons} + +cp "$root_dir/bin/wechat-devtools" "$app_dir/bin/wechat-devtools" +cp "$root_dir/res/appimage.desktop" "$app_dir/wechat-devtools.desktop" +cp "$root_dir/res/icons/wechat-devtools.png" "$app_dir/wechat-devtools.png" + +echo "#!/bin/bash" > "$app_dir/AppRun" +echo "exec bin/wechat-devtools" >> "$app_dir/AppRun" +chmod +x "$app_dir/AppRun" + +cp -r "$root_dir/package.nw" "$app_dir/package.nw" +cp -r "$root_dir/nwjs" "$app_dir/nwjs" +rm -rf "$app_dir/nwjs/node" "$app_dir/nwjs/node.exe" +cp -r "$root_dir/node/bin/node" "$app_dir/nwjs/node" +cd "$app_dir/nwjs/" && ln -s "node" "node.exe" +cd "$app_dir" diff --git a/tools/fix-wcc-wcsc b/tools/fix-wcc-wcsc old mode 100644 new mode 100755 diff --git a/tools/setup-wechat-devtools-bash b/tools/setup-wechat-devtools-bash old mode 100644 new mode 100755