diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 748cdb2..8e4291c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,9 +27,11 @@ jobs: build: [ legacy, modern ] include: - build: legacy - BUILD_ARGS: + BUILD_ARGS: "" + BUILD_EXTENSION: true - build: modern BUILD_ARGS: "-- --modern" + BUILD_EXTENSION: false steps: - uses: actions/checkout@v2 @@ -59,8 +61,21 @@ jobs: npm run build ${{ matrix.BUILD_ARGS }} tar -czvf dist.tar.gz -C ./dist . + - name: Build Extension + if: ${{ matrix.BUILD_EXTENSION }} + run: | + npm run make-extension + zip -rJ9 extension.zip ./dist + - name: Publish artifact uses: actions/upload-artifact@v2 with: name: unlock-music-${{ matrix.build }}.tar.gz path: ./dist.tar.gz + + - name: Publish artifact - Extension + if: ${{ matrix.BUILD_EXTENSION }} + uses: actions/upload-artifact@v2 + with: + name: extension.zip + path: ./extension.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1e4370..3a1645a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,6 +37,8 @@ jobs: npm run build tar -czf legacy.tar.gz -C ./dist . zip -rJ9 legacy.zip ./dist + npm run make-extension + zip -rJ9 extension.zip ./dist - name: Build Modern env: @@ -109,6 +111,16 @@ jobs: asset_name: modern.zip asset_content_type: application/zip + - name: Upload Release Assets - extension.zip + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./extension.zip + asset_name: extension.zip + asset_content_type: application/zip + - name: Upload Release Assets - sha256sum.txt uses: actions/upload-release-asset@v1.0.2 env: diff --git a/extension-manifest.json b/extension-manifest.json new file mode 100644 index 0000000..9aa8b61 --- /dev/null +++ b/extension-manifest.json @@ -0,0 +1,16 @@ +{ + "manifest_version": 2, + "name": "音乐解锁", + "short_name": "音乐解锁", + "icons": { + "128": "./img/icons/msapplication-icon-144x144.png" + }, + "description": "在任何设备上解锁已购的加密音乐!", + "offline_enabled": true, + "options_page": "./index.html", + "homepage_url": "https://github.com/ix64/unlock-music", + "browser_action": { + "default_popup": "./popup.html" + }, + "content_security_policy": "script-src 'self' https://stats.ixarea.com; object-src 'self'" +} diff --git a/make-extension.js b/make-extension.js new file mode 100644 index 0000000..2f68dd0 --- /dev/null +++ b/make-extension.js @@ -0,0 +1,20 @@ +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) + +manifest["version"] = pkg["version"] +fs.writeFileSync("./dist/manifest.json", JSON.stringify(manifest), "utf-8") +console.log("Write: manifest.json") diff --git a/package.json b/package.json index b97884f..25e7f44 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", - "fix-compatibility": "node ./src/fix-compatibility.js" + "fix-compatibility": "node ./src/fix-compatibility.js", + "make-extension": "node ./make-extension.js" }, "dependencies": { "base64-js": "^1.5.1", diff --git a/public/index.html b/public/index.html index bd60e18..33e39ab 100644 --- a/public/index.html +++ b/public/index.html @@ -5,13 +5,10 @@ - - - -