Compare commits

...

11 Commits

Author SHA1 Message Date
8bc4b1d109 Merge pull request '使用 DroneCI 自动构建' (#13) from ci/build-with-drone into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #13
2022-11-26 21:05:39 +00:00
278104644c ci: better glob for file upload
Some checks reported errors
continuous-integration/drone/pr Build was killed
continuous-integration/drone/push Build is passing
2022-11-26 20:59:08 +00:00
ab2b37ba3c chore: gitignore sha256sum.txt
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-11-26 20:34:04 +00:00
3c79a1f6e2 fix: syntax error for compare text in shell script
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build is passing
2022-11-26 20:21:43 +00:00
e79728c687 fix: drone build script
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2022-11-26 20:11:13 +00:00
9b3dfc0ed6 fix: keep dist after legacy has built 2022-11-26 20:11:05 +00:00
c5adc9dc05 chore: add nvmrc
Some checks failed
continuous-integration/drone/push Build is failing
2022-11-26 20:02:56 +00:00
b480088bb6 chore: don't prefix version string with "v" in package.json. 2022-11-26 20:02:52 +00:00
49b31301cf ci: initial experiment with ci build
Some checks failed
continuous-integration/drone/push Build is failing
2022-11-26 19:59:26 +00:00
892fea509f test: remove invalid test and avoid jest pick up tests from emsdk folder. 2022-11-26 19:21:30 +00:00
38cc5e2189 chore: share the same emsdk path. 2022-11-26 19:08:08 +00:00
12 changed files with 131 additions and 83 deletions

37
.drone.yml Normal file
View File

@ -0,0 +1,37 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: build
image: node:16.18-bullseye
commands:
- apt-get update
- apt-get install -y cmake jq zip
- ./scripts/build-wasm.sh
- npm ci
- npm run test
- ./scripts/build-and-package.sh legacy
- ./scripts/build-and-package.sh extension
- ./scripts/build-and-package.sh modern
- sha256sum *.zip > sha256sum.txt
- mkdir -p upload
- mv *.zip sha256sum.txt upload/
- name: upload
image: "plugins/s3"
settings:
path_style: true
endpoint:
from_secret: S3_ENDPOINT
access_key:
from_secret: S3_ACCESS_KEY
secret_key:
from_secret: S3_SECRET_KEY
bucket:
from_secret: S3_BUCKET
region: "auto"
source: "upload/*"
strip_prefix: "upload/"
target: "${DRONE_REPO}/${DRONE_BUILD_NUMBER}/"

5
.gitignore vendored
View File

@ -1,6 +1,7 @@
.DS_Store
node_modules
/dist
/build
/coverage
# local env files
@ -27,3 +28,7 @@ yarn-error.log*
/src/QmcWasm/build
/src/QmcWasm/*.js
/src/QmcWasm/*.wasm
*.zip
*.tar.gz
/sha256sum.txt

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
v16.18.1

View File

@ -44,8 +44,8 @@
### 自行构建
#### JS部分
#### JS部分
- 环境要求
- nodejs (v16.x)
- npm
@ -70,15 +70,15 @@
```sh
npm run make-extension
```
#### WASM部分
- 环境要求
- Linux
- python3
- 运行此目录下的build-wasm
```sh
bash build-wasm
```
#### WASM部分
- 环境要求
- Linux
- python3
- 运行此目录下的build-wasm
```sh
./scripts/build-wasm.sh
```

View File

@ -1,8 +1,7 @@
module.exports = {
setupFilesAfterEnv: [
'./src/__test__/setup_jest.js'
],
moduleNameMapper: {
'@/(.*)': '<rootDir>/src/$1'
}
};
module.exports = {
testPathIgnorePatterns: ['/build/', '/dist/', '/node_modules/'],
setupFilesAfterEnv: ['./src/__test__/setup_jest.js'],
moduleNameMapper: {
'@/(.*)': '<rootDir>/src/$1',
},
};

View File

@ -1,25 +1,25 @@
const fs = require('fs')
const path = require('path')
const src = "./src/extension/"
const dst = "./dist"
fs.readdirSync(src).forEach(file => {
let srcPath = path.join(src, file)
let dstPath = path.join(dst, file)
fs.copyFileSync(srcPath, dstPath)
console.log(`Copy: ${srcPath} => ${dstPath}`)
})
const manifestRaw = fs.readFileSync("./extension-manifest.json", "utf-8")
const manifest = JSON.parse(manifestRaw)
const pkgRaw = fs.readFileSync("./package.json", "utf-8")
const pkg = JSON.parse(pkgRaw)
verExt = pkg["version"]
if (verExt.startsWith("v")) verExt = verExt.slice(1)
if (verExt.includes("-")) verExt = verExt.split("-")[0]
manifest["version"] = `${verExt}.${pkg["ext_build"]}`
manifest["version_name"] = pkg["version"]
fs.writeFileSync("./dist/manifest.json", JSON.stringify(manifest), "utf-8")
console.log("Write: manifest.json")
const fs = require('fs')
const path = require('path')
const src = __dirname + "/src/extension/"
const dst = __dirname + "/dist"
fs.readdirSync(src).forEach(file => {
let srcPath = path.join(src, file)
let dstPath = path.join(dst, file)
fs.copyFileSync(srcPath, dstPath)
console.log(`Copy: ${srcPath} => ${dstPath}`)
})
const manifestRaw = fs.readFileSync(__dirname + "/extension-manifest.json", "utf-8")
const manifest = JSON.parse(manifestRaw)
const pkgRaw = fs.readFileSync(__dirname + "/package.json", "utf-8")
const pkg = JSON.parse(pkgRaw)
verExt = pkg["version"]
if (verExt.startsWith("v")) verExt = verExt.slice(1)
if (verExt.includes("-")) verExt = verExt.split("-")[0]
manifest["version"] = `${verExt}.${pkg["ext_build"]}`
manifest["version_name"] = pkg["version"]
fs.writeFileSync(__dirname + "/dist/manifest.json", JSON.stringify(manifest), "utf-8")
console.log("Write: manifest.json")

View File

@ -1,6 +1,6 @@
{
"name": "unlock-music",
"version": "v1.10.3",
"version": "1.10.3",
"ext_build": 0,
"updateInfo": "完善音乐标签编辑功能,支持编辑更多标签",
"license": "MIT",
@ -56,4 +56,4 @@
"vue-cli-plugin-element": "^1.0.1",
"vue-template-compiler": "^2.6.14"
}
}
}

29
scripts/build-and-package.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
set -ex
cd "$(git rev-parse --show-toplevel)"
VERSION="$(jq -r ".version" <package.json)"
DIST_NAME="um-web.$1.v${VERSION}"
case "$1" in
"modern") npm run build -- --modern ;;
"legacy") npm run build ;;
"extension") npm run make-extension ;;
*)
echo "Unknown command: $1"
exit 1
;;
esac
mv dist "${DIST_NAME}"
zip -rJ9 "${DIST_NAME}.zip" "${DIST_NAME}"
if [ "$1" = "legacy" ]; then
# For upcoming extension build
mv "${DIST_NAME}" dist
else
rm -rf "${DIST_NAME}"
fi

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -e
set -ex
cd "$(git rev-parse --show-toplevel)"
pushd ./src/QmcWasm
bash build-wasm

View File

@ -12,16 +12,16 @@ if [ -z "$BUILD_TYPE" ]; then
fi
mkdir -p build/wasm
if [ ! -d build/emsdk ]; then
git clone https://github.com/emscripten-core/emsdk.git build/emsdk
if [ ! -d ../../build/emsdk ]; then
git clone https://github.com/emscripten-core/emsdk.git ../../build/emsdk
fi
pushd build/emsdk
pushd ../../build/emsdk
#git pull
./emsdk install 3.0.0
./emsdk activate 3.0.0
source ./emsdk_env.sh
popd # build/emsdk
popd # ../../build/emsdk
pushd build/wasm
emcmake cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" ../..
@ -33,8 +33,6 @@ TARGET_FILES="
KgmWasmBundle.js
"
#mkdir -p "${CURR_DIR}/npm"
#cp $TARGET_FILES "${CURR_DIR}/npm/"
cp $TARGET_FILES "${CURR_DIR}/"
popd # build/wasm

View File

@ -12,16 +12,15 @@ if [ -z "$BUILD_TYPE" ]; then
fi
mkdir -p build/wasm
if [ ! -d build/emsdk ]; then
git clone https://github.com/emscripten-core/emsdk.git build/emsdk
if [ ! -d ../../build/emsdk ]; then
git clone https://github.com/emscripten-core/emsdk.git ../../build/emsdk
fi
pushd build/emsdk
#git pull
pushd ../../build/emsdk
./emsdk install 3.0.0
./emsdk activate 3.0.0
source ./emsdk_env.sh
popd # build/emsdk
popd # ../../build/emsdk
pushd build/wasm
emcmake cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" ../..
@ -33,8 +32,6 @@ TARGET_FILES="
QmcWasmBundle.js
"
#mkdir -p "${CURR_DIR}/npm"
#cp $TARGET_FILES "${CURR_DIR}/npm/"
cp $TARGET_FILES "${CURR_DIR}/"
popd # build/wasm

View File

@ -1,20 +0,0 @@
// import { DecryptBuffer as DecryptQmcCacheBuffer } from '../qmccache';
// import fs from 'fs';
//
// const expectedBuffer = fs.readFileSync(__dirname + '/fixture/qmc_cache_expected.bin');
//
// const createInputBuffer = () => {
// const buffer = Buffer.alloc(256);
// for (let i = buffer.byteLength; i >= 0; i--) {
// buffer[i] = i;
// }
// return buffer;
// };
//
// describe('decrypt/qmccache', () => {
// it('should decrypt specified buffer correctly', () => {
// const input = createInputBuffer();
// DecryptQmcCacheBuffer(input);
// expect(input).toEqual(expectedBuffer);
// });
// });