From 0e50490049e5a19e3234abeb4b21c26379ae1241 Mon Sep 17 00:00:00 2001 From: msojocs Date: Mon, 25 Apr 2022 13:14:43 +0800 Subject: [PATCH 1/3] update: snap version data feat: snap build action --- .github/workflows/release.yml | 38 ++++++++++++++++++++++++++++++++--- .husky/pre-commit | 16 +++++++++++---- snap/snapcraft.yaml | 4 ++-- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e3995c..5ee9e07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ on: push: tags: - v* - branches: [ master, dev] + branches: [ master, dev, 45-snap-version] pull_request: branches: [ master ] # # Allows you to run this workflow manually from the Actions tab @@ -328,6 +328,37 @@ jobs: name: wechat-devtools-${{ matrix.ARCH }}.build path: tmp/build + build-snap: + name: Build Snap Package + runs-on: ubuntu-18.04 + timeout-minutes: 30 + strategy: + matrix: + ARCH: ['x86_64'] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Install Snapcraft + uses: samuelmeuli/action-snapcraft@v1 + with: + use_lxd: true + + # You can now run Snapcraft shell commands + - name: Build snap + run: sg lxd -c 'snapcraft --use-lxd' + + - name: move file + run: | + mkdir -p tmp/build + mv *.snap tmp/build + - 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: @@ -362,7 +393,7 @@ jobs: 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 **build/WeChat*.AppImage **build/*.tar.gz **build/*.deb **build/*.pkg.* + ./pyuploadtool-x86_64.AppImage **build/WeChat*.AppImage **build/*.tar.gz **build/*.deb **build/*.pkg.* **build/*.snap - name: Release uses: softprops/action-gh-release@v1 @@ -376,4 +407,5 @@ jobs: **build/WeChat*.AppImage **build/*.tar.gz **build/*.deb - **build/*.pkg.* \ No newline at end of file + **build/*.pkg.* + **build/*.snap \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 6a35ec2..2ab12eb 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -11,10 +11,18 @@ VERSION_DATA=(${VERSION_DATA//,/ }) TARGET_VERSION=${VERSION_DATA[0]} TARGET_VERSION_MD5=${VERSION_DATA[1]} -# 获取snapcraft中的版本号 +# 检查snapcraft主版本号是否正确 SNAP_VERSION=$(find $root_dir/snap -name "snapcraft.yaml" | xargs grep -P "'\d+\.\d+\.\d{5,}" -o) - -if [ "$SNAP_VERSION" != "'$TARGET_VERSION" ];then - echo "SNAP版本不匹配!!!" +if [ "${SNAP_VERSION//\'/}" != "$TARGET_VERSION" ];then + echo "SNAP版本不匹配!!!" + echo "SNAP版本: $SNAP_VERSION != 目标版本: $TARGET_VERSION" + exit 1 +fi + +# 检查snapcraft构建时下载的工具版本号是否正确 +SNAP_DEVTOOL_VERSION=$(find $root_dir/snap -name "snapcraft.yaml" | xargs grep -P "=\d+\d+\d{5,}" -o) +if [ "${SNAP_DEVTOOL_VERSION//=/}" != "${TARGET_VERSION//./}" ];then + echo "SNAP工具版本不匹配!!!" + echo "snap下载版本: ${SNAP_DEVTOOL_VERSION//=/} != 目标版本: ${TARGET_VERSION//./}" exit 1 fi diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index e3e0022..9334e4a 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -32,8 +32,8 @@ parts: ls -l $SNAPCRAFT_PART_INSTALL package-nw: plugin: dump - source: https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=1052203070&version_type=1 - # source: cache/wechat_devtools_1.05.2203070_x64.exe + source: https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=1052204180&version_type=1 + # source: cache/wechat_devtools_1.05.2204180_x64.exe source-type: 7z source-subdir: code override-build: | From 6ca62fe4c88ddcfd6db66969c6326cbb5ed85d26 Mon Sep 17 00:00:00 2001 From: msojocs Date: Mon, 25 Apr 2022 14:24:26 +0800 Subject: [PATCH 2/3] Update release.yml --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ee9e07..6c9d1e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -364,7 +364,7 @@ jobs: needs: - build-tar - build-deb - # - build-deepin + - build-snap - build-arch runs-on: ubuntu-latest steps: @@ -408,4 +408,4 @@ jobs: **build/*.tar.gz **build/*.deb **build/*.pkg.* - **build/*.snap \ No newline at end of file + **build/*.snap From 0014eac997e7d63d33ebbe1262d220bce4a08722 Mon Sep 17 00:00:00 2001 From: msojocs Date: Mon, 25 Apr 2022 19:09:41 +0800 Subject: [PATCH 3/3] update: check version of snap --- .husky/pre-commit | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 2ab12eb..1fd22d6 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -11,11 +11,13 @@ VERSION_DATA=(${VERSION_DATA//,/ }) TARGET_VERSION=${VERSION_DATA[0]} TARGET_VERSION_MD5=${VERSION_DATA[1]} +LATEST_TAG=$(git describe --abbrev=0) + # 检查snapcraft主版本号是否正确 -SNAP_VERSION=$(find $root_dir/snap -name "snapcraft.yaml" | xargs grep -P "'\d+\.\d+\.\d{5,}" -o) -if [ "${SNAP_VERSION//\'/}" != "$TARGET_VERSION" ];then - echo "SNAP版本不匹配!!!" - echo "SNAP版本: $SNAP_VERSION != 目标版本: $TARGET_VERSION" +SNAP_VERSION=$(find $root_dir/snap -name "snapcraft.yaml" | xargs grep -P "'\d+\.\d+\.\d+-\d+" -o) +if [ "v${SNAP_VERSION//\'/}" != "$LATEST_TAG" ];then + echo "SNAP版本不正确!!!" + echo "SNAP版本: v${SNAP_VERSION//\'/} != 最新TAG: $LATEST_TAG" exit 1 fi