diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb888bb..9690c9f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,57 +1,39 @@ name: Release CI - + on: push: - # Sequence of patterns matched against refs/tags tags: - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + workflow_dispatch: jobs: - create-release: - runs-on: ubuntu-latest - outputs: - RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }} - - steps: - - uses: actions/checkout@v2 - - name: Query version number - id: get_version - shell: bash - run: | - echo "using version tag ${GITHUB_REF:10}" - echo ::set-output name=version::"${GITHUB_REF:10}" - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: '${{ steps.get_version.outputs.VERSION }}' - release_name: 'BiliTools | ${{ steps.get_version.outputs.VERSION }}' - body: 'See the assets to download this version and install.' - build-tauri: - needs: create-release + permissions: + contents: write strategy: fail-fast: false matrix: - platform: [macos-latest, ubuntu-latest, windows-latest] + # platform: [macos-latest, ubuntu-20.04, windows-latest] + platform: [windows-latest] runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v2 + - name: Checkout original repository + uses: actions/checkout@v4 + with: + ref: master - name: Setup node uses: actions/setup-node@v1 with: - node-version: 16 + node-version: 18 - name: Install Rust stable uses: actions-rs/toolchain@v1 with: toolchain: stable + # Rust cache - uses: Swatinem/rust-cache@v1 - name: install dependencies (ubuntu only) @@ -60,59 +42,35 @@ jobs: sudo apt-get update sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - - - name: Yarn cache + - name: Get npm cache directory path + id: npm-cache-dir-path + run: echo "::set-output name=dir::$(npm config get cache)" + + - name: Npm cache uses: actions/cache@v2 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + path: ${{ steps.npm-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-yarn- + ${{ runner.os }}-npm- + + - name: Install app dependencies + run: npm install - - name: Install app dependencies and build it - run: yarn && yarn build - uses: tauri-apps/tauri-action@v0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PAT }} TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} with: - releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }} - - # 生成静态资源并将其推送到公仓 - updater: - runs-on: ubuntu-latest - needs: [create-release, build-tauri] - - steps: - - uses: actions/checkout@v2 - - run: yarn - - run: yarn updater + tagName: v__VERSION__ + releaseName: 'BiliTools | v__VERSION__' + releaseBody: 'See the assets to download this version and install.' + releaseDraft: false + prerelease: false + includeUpdaterJson: false + + - name: Init and deploy install.json + run: npm run updater env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Checkout btjawa/BiliTools repository - uses: actions/checkout@v2 - with: - repository: btjawa/BiliTools - token: ${{ secrets.PAT }} - path: 'BiliTools' - fetch-depth: 0 # 确保获取所有历史记录以便正确定位分支 - - - name: Copy files to BiliTools repository - run: | - cp -r ./updater/* ./BiliTools/ - - - name: Commit and push to updater branch - run: | - cd BiliTools - git checkout updater || git checkout -b updater - git config --global user.name 'GitHub Actions' - git config --global user.email 'actions@github.com' - git add . - git commit -m "Update updater branch" - git push --set-upstream origin updater \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.PAT }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 25615d9..c0edeb6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,8 @@ dist-ssr *.njsproj *.sln *.sw? -assets/* \ No newline at end of file +assets/* +!assets/preview.png + +png_to_ico.exe +test.txt \ No newline at end of file diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md new file mode 100644 index 0000000..e06582d --- /dev/null +++ b/UPDATE_LOG.md @@ -0,0 +1,15 @@ +# Updater Log + +## v1.0.0 + +更名为 "BiliTools", 全新图标 +- 功能: 下载相关 + - 支持 8K & Hi-Res无损 & 杜比视界 + 全景声 & 编码格式 + - 并发下载, 多个视频将会打包在一个文件夹内 +- 功能: 登录相关 + - 个人主页 + - 扫码 & 密码 & 短信登录 + 自动刷新登录状态 +- 功能: 杂项更新 + - 现在可以设置了 - 引入配置文件 + - 自动检测新版本并更新 +- 修复: 提高操作安全性 - 不再使用反代服务器解决CORS \ No newline at end of file diff --git a/assets/preview.png b/assets/preview.png new file mode 100644 index 0000000..cb3f17d Binary files /dev/null and b/assets/preview.png differ diff --git a/package-lock.json b/package-lock.json index ce83619..2e8d203 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bilitools", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bilitools", - "version": "0.1.0", + "version": "1.0.0", "license": "MIT", "dependencies": { "@actions/github": "^6.0.0", diff --git a/package.json b/package.json index 2c091fe..af5adfb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bilitools", - "version": "0.1.0", - "description": "Download Videos/Covers/Audios/Danmakus... All in one!", + "version": "1.0.0", + "description": "bilibili工具箱,视频/番剧+音频下载,三种登录方式,仅用作学习用途。", "type": "module", "scripts": { "tauri": "tauri", @@ -26,4 +26,4 @@ "@actions/github": "^6.0.0", "node-fetch": "^3.3.2" } -} +} \ No newline at end of file diff --git a/scripts/release.mjs b/scripts/release.mjs index c47f989..6279b0d 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -9,6 +9,7 @@ const require = createRequire(import.meta.url); async function release() { const flag = process.argv[2] ?? 'patch'; const packageJson = require('../package.json'); + const tauriConfig = require('../src-tauri/tauri.conf.json'); let [a, b, c] = packageJson.version.split('.').map(Number); if (flag === 'major') { // 主版本 @@ -26,16 +27,18 @@ async function release() { } const nextVersion = `${a}.${b}.${c}`; + tauriConfig.package.version = nextVersion; packageJson.version = nextVersion; const nextTag = `v${nextVersion}`; await updatelog(nextTag, 'release'); - // 将新版本写入 package.json 文件 + // 将新版本写入 package.json 与 tauri.conf.json 文件 fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2)); + fs.writeFileSync('./src-tauri/tauri.conf.json', JSON.stringify(tauriConfig, null, 2)); - // 提交修改的文件,打 tag 标签(tag 标签是为了触发 github action 工作流)并推送到远程 - execSync('git add ./package.json ./UPDATE_LOG.md'); + // 提交文件,打 tag 标签(tag 标签是为了触发 github action 工作流)并推送到远程 + execSync('git add -A'); execSync(`git commit -m "v${nextVersion}"`); execSync(`git tag -a v${nextVersion} -m "v${nextVersion}"`); execSync(`git push`); diff --git a/scripts/updater.mjs b/scripts/updater.mjs index 620d97b..258827f 100644 --- a/scripts/updater.mjs +++ b/scripts/updater.mjs @@ -1,6 +1,8 @@ import fetch from 'node-fetch'; import { getOctokit, context } from '@actions/github'; +import { execSync } from 'child_process'; import fs from 'fs'; +import path from 'path'; import updatelog from './updatelog.mjs'; @@ -43,11 +45,6 @@ async function updater() { pub_date: new Date().toISOString(), platforms: { win64: { signature: '', url: '' }, // compatible with older formats - linux: { signature: '', url: '' }, // compatible with older formats - darwin: { signature: '', url: '' }, // compatible with older formats - 'darwin-aarch64': { signature: '', url: '' }, - 'darwin-x86_64': { signature: '', url: '' }, - 'linux-x86_64': { signature: '', url: '' }, 'windows-x86_64': { signature: '', url: '' }, // 'windows-i686': { signature: '', url: '' }, // no supported }, @@ -56,7 +53,7 @@ async function updater() { const setAsset = async (asset, reg, platforms) => { let sig = ''; if (/.sig$/.test(asset.name)) { - sig = await getSignature(asset.browser_download_url); + sig = await getSignature(`https://gh.con.sh/${asset.browser_download_url}`); } platforms.forEach((platform) => { if (reg.test(asset.name)) { @@ -66,7 +63,7 @@ async function updater() { return; } // 设置下载链接 - updateData.platforms[platform].url = asset.browser_download_url; + updateData.platforms[platform].url = `https://gh.con.sh/${asset.browser_download_url}`; } }); }; @@ -74,29 +71,21 @@ async function updater() { const promises = latestRelease.assets.map(async (asset) => { // windows await setAsset(asset, /.msi.zip/, ['win64', 'windows-x86_64']); - - // darwin - await setAsset(asset, /.app.tar.gz/, [ - 'darwin', - 'darwin-x86_64', - 'darwin-aarch64', - ]); - - // linux - await setAsset(asset, /.AppImage.tar.gz/, ['linux', 'linux-x86_64']); }); await Promise.allSettled(promises); - if (!fs.existsSync('updater')) { - fs.mkdirSync('updater'); - } - // 将数据写入文件 fs.writeFileSync( - './updater/install.json', + path.join(process.cwd(), 'install.json'), JSON.stringify(updateData, null, 2) ); - console.log('Generate updater/install.json'); + console.log('Generate install.json'); + execSync('git config user.name github-actions'); + execSync('git config user.email github-actions@github.com'); + execSync('git add -A'); + execSync(`git commit -m "Update install.json"`); + execSync(`git push origin HEAD:master`); + console.log(`Publish Successfully...`); } updater().catch(console.error); diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 4095ce9..05950a0 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -138,7 +138,7 @@ checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bilitools" -version = "0.1.0" +version = "1.0.0" dependencies = [ "chrono", "futures", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1fc9f93..6960d21 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bilitools" -version = "0.1.0" +version = "1.0.0" description = "BiliTools" authors = ["btjawa"] license = "MIT" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 5e2f303..021bd53 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "BiliTools", - "version": "0.1.0" + "version": "1.0.0" }, "tauri": { "allowlist": { @@ -27,7 +27,9 @@ "http": { "all": false, "request": true, - "scope": ["https://*.bilibili.com/*"] + "scope": [ + "https://*.bilibili.com/*" + ] } }, "bundle": { @@ -46,7 +48,12 @@ "active": true, "dialog": true, "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEVFQTUzQTQ3NDY3RUZEMjgKUldRby9YNUdSenFsN3JJYklTL0g5RUd2QkhUWklqQUxydVZXdFA4c25ZazI0YjJIbTFFM0JiNjkK", - "endpoints": ["https://gh.con.sh/https://github.com/btjawa/BiliTools/blob/gh-pages/install.json"] + "endpoints": [ + "https://gh.con.sh/https://github.com/btjawa/BiliTools/blob/master/install.json" + ], + "windows": { + "installMode": "passive" + } }, "security": { "csp": null @@ -66,4 +73,4 @@ } ] } -} +} \ No newline at end of file