Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
btjawa committed Jan 1, 2024
1 parent 2f73186 commit d06b2f8
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 114 deletions.
110 changes: 34 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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 '[email protected]'
git add .
git commit -m "Update updater branch"
git push --set-upstream origin updater
GITHUB_TOKEN: ${{ secrets.PAT }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ dist-ssr
*.njsproj
*.sln
*.sw?
assets/*
assets/*
!assets/preview.png

png_to_ico.exe
test.txt
15 changes: 15 additions & 0 deletions UPDATE_LOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Updater Log

## v1.0.0

更名为 "BiliTools", 全新图标
- 功能: 下载相关
- 支持 8K & Hi-Res无损 & 杜比视界 + 全景声 & 编码格式
- 并发下载, 多个视频将会打包在一个文件夹内
- 功能: 登录相关
- 个人主页
- 扫码 & 密码 & 短信登录 + 自动刷新登录状态
- 功能: 杂项更新
- 现在可以设置了 - 引入配置文件
- 自动检测新版本并更新
- 修复: 提高操作安全性 - 不再使用反代服务器解决CORS
Binary file added assets/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -26,4 +26,4 @@
"@actions/github": "^6.0.0",
"node-fetch": "^3.3.2"
}
}
}
9 changes: 6 additions & 3 deletions scripts/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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') { // 主版本
Expand All @@ -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`);
Expand Down
35 changes: 12 additions & 23 deletions scripts/updater.mjs
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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
},
Expand All @@ -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)) {
Expand All @@ -66,37 +63,29 @@ async function updater() {
return;
}
// 设置下载链接
updateData.platforms[platform].url = asset.browser_download_url;
updateData.platforms[platform].url = `https://gh.con.sh/${asset.browser_download_url}`;
}
});
};

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 [email protected]');
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);
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bilitools"
version = "0.1.0"
version = "1.0.0"
description = "BiliTools"
authors = ["btjawa"]
license = "MIT"
Expand Down
15 changes: 11 additions & 4 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "BiliTools",
"version": "0.1.0"
"version": "1.0.0"
},
"tauri": {
"allowlist": {
Expand All @@ -27,7 +27,9 @@
"http": {
"all": false,
"request": true,
"scope": ["https://*.bilibili.com/*"]
"scope": [
"https://*.bilibili.com/*"
]
}
},
"bundle": {
Expand All @@ -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
Expand All @@ -66,4 +73,4 @@
}
]
}
}
}

0 comments on commit d06b2f8

Please sign in to comment.