diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5f61d4b..a3b0f4c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,10 +17,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Node v20.9.x + - name: Setup Node v20.9.0 uses: actions/setup-node@v4 with: - node-version: '20.14.x' + node-version: '20.14.0' registry-url: "https://npm.pkg.github.com" scope: "@paulober" token: ${{ secrets.GITHUB_TOKEN }} @@ -38,22 +38,25 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish - run: ./scripts/publish.sh + - name: Run Publish Script + run: | + chmod +x ./scripts/publish.sh + ./scripts/publish.sh env: VSCE_PAT: ${{ secrets.VSCE_PAT }} OVSX_PAT: ${{ secrets.OPEN_VSX_TOKEN }} - + RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} + - name: Upload Artifacts uses: actions/upload-artifact@v4 with: - name: Visual Studio Code extension package - path: pico-w-go-*.vsix + name: MicroPico ${{ github.event.release.tag_name }} + path: micropico-*.vsix - name: Upload Artifact To Release - #gh api --method POST -H "Accept: application/vnd.github+json" /repos/paulober/MicroPico/releases/$RELEASE_ID/assets - run: gh release upload $RELEASE_TAG_NAME pico-w-go-*.vsix + #gh api --method POST -H "Accept: application/vnd.github+json" /repos/paulober/MicroPico/releases/$RELEASE_ID/assets + run: gh release upload $RELEASE_TAG_NAME micropico-*.vsix env: - #RELEASE_ID: ${{ github.event.release.id }} + #RELEASE_ID: $ {{ github.event.release.id }} RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 2d48c12..1bbff19 100644 --- a/package.json +++ b/package.json @@ -603,10 +603,11 @@ "vscode:uninstall": "node ./dist/vscodeUninstall.mjs", "vscode:prepublish": "npm run package", "postinstall": "python -m pip install -U micropython-rp2-rpi_pico_w-stubs==1.23.* --target ./mpy_stubs --no-user", - "compile-uninstaller": "rollup -c uninstall.rollup.config.mjs", + "compile-uninstaller": "rollup -c uninstall.rollup.config.mjs --environment BUILD:production", "compile": "rollup -c && npm run compile-uninstaller", "watch": "rollup -cw", - "package": "rimraf dist && rollup -c --environment BUILD:production --sourcemap hidden && npm run compile-uninstaller", + "package-local": "rimraf dist && rollup -c --environment BUILD:production --sourcemap hidden && npm run compile-uninstaller", + "package": "rollup -c --environment BUILD:production --sourcemap hidden && npm run compile-uninstaller", "compile-tests": "tsc -p . --outDir out", "watch-tests": "tsc -p . -w --outDir out", "pretest": "npm run compile-tests && npm run compile && npm run lint", diff --git a/rollup.config.mjs b/rollup.config.mjs index 77c9c6d..a7dd145 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -2,7 +2,6 @@ import commonjs from '@rollup/plugin-commonjs'; import { nodeResolve } from '@rollup/plugin-node-resolve'; import terser from '@rollup/plugin-terser'; import typescript from '@rollup/plugin-typescript'; -import copy from 'rollup-plugin-copy'; import json from '@rollup/plugin-json'; const isProduction = process.env.BUILD === 'production'; @@ -20,14 +19,15 @@ export default { 'vscode' ], plugins: [ - isProduction && copy({ + // moved to publish.sh + /*isProduction && copy({ targets: [ { src: 'node_modules/@serialport/bindings-cpp/prebuilds', dest: './' }, ], - }), + }),*/ nodeResolve({ preferBuiltins: true, }), diff --git a/scripts/publish.sh b/scripts/publish.sh index 2fb113d..d55446f 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -1,45 +1,48 @@ #!/bin/bash # This script's purpose is to publish the VSCode extension to the VSCode Marketplace -# and package binaries for each platform to reduced vsix size - -# Run npm run package (not needed as prepublish script already runs it) -#npm run package - -# Create a folder dist/scripts if it doesn't exist -mkdir -p dist/scripts +# and OpenVSX Registry also it packages binaries for each +# platform to reduced vsix size # Define an array of platforms -platforms=("win32" "macOS_arm64" "macOS_amd64" "linux_arm64" "linux_armhf" "linux_amd64") +platforms=("win32-x64" "darwin-x64+arm64" "linux-arm64" "linux-arm" "linux-x64" "universal") +rm -rf dist # Loop through the platforms for platform in "${platforms[@]}"; do - # Copy the scripts to dist/scripts for each platform - cp -r "node_modules/@paulober/pyboard-serial-com/scripts/wrapper_$platform" "dist/scripts" + rm -rf prebuilds + mkdir prebuilds + + if [ "$platform" != "universal" ]; then + # Copy the bindings binary for each platform + cp -r "node_modules/@serialport/bindings-cpp/prebuilds/$platform" "./prebuilds" + else + # Copy the bindings binaries for all platforms + cp -r "node_modules/@serialport/bindings-cpp/prebuilds" "./" + fi # Package the VSCode extension for the platform - if [ "$platform" == "win32" ]; then - npx @vscode/vsce package --no-yarn --target "win32-x64" - elif [ "$platform" == "macOS_arm64" ]; then - npx @vscode/vsce package --no-yarn --target "darwin-arm64" - elif [ "$platform" == "macOS_amd64" ]; then - npx @vscode/vsce package --no-yarn --target "darwin-x64" - elif [ "$platform" == "linux_arm64" ]; then - npx @vscode/vsce package --no-yarn --target "linux-arm64" - elif [ "$platform" == "linux_armhf" ]; then - npx @vscode/vsce package --no-yarn --target "linux-armhf" - elif [ "$platform" == "linux_amd64" ]; then - npx @vscode/vsce package --no-yarn --target "linux-x64" + if [ "$platform" == "win32-x64" ]; then + npx @vscode/vsce package --no-yarn --target "win32-x64" -o "micropico-$RELEASE_TAG_NAME-$platform.vsix" + elif [ "$platform" == "darwin-x64+arm64" ]; then + npx @vscode/vsce package --no-yarn --target "darwin-arm64 darwin-x64" -o "micropico-$RELEASE_TAG_NAME-$platform.vsix" + elif [ "$platform" == "linux-arm64" ]; then + npx @vscode/vsce package --no-yarn --target "linux-arm64" -o "micropico-$RELEASE_TAG_NAME-$platform.vsix" + elif [ "$platform" == "linux-arm" ]; then + npx @vscode/vsce package --no-yarn --target "linux-armhf" -o "micropico-$RELEASE_TAG_NAME-linux-armhf.vsix" + elif [ "$platform" == "linux-x64" ]; then + npx @vscode/vsce package --no-yarn --target "linux-x64" -o "micropico-$RELEASE_TAG_NAME-$platform.vsix" + else + npx @vscode/vsce package --no-yarn -o "micropico-$RELEASE_TAG_NAME.vsix" fi - - # Remove the copied scripts for the current platform - rm -r "dist/scripts/wrapper_$platform" done -# Find all .vsix files and publish them one by one -find . -name "*.vsix" -type f | while read -r package_path; do +# Find all .vsix files except the one without a platform prefix and publish them one by one +find . -type f -name "micropico-$RELEASE_TAG_NAME-*.vsix" ! -name "micropico-$RELEASE_TAG_NAME.vsix" | while read file -r package_path; do # Publish the VSCode extension to the VSCode Marketplace npx @vscode/vsce publish --packagePath "$package_path" # Publish the VSCode extension to the Open VSX Registry - #npx ovsx publish "$package_path" -p "$OVSX_PAT" + npx ovsx publish "$package_path" -p "$OVSX_PAT" + # delete this vsix file + rm -rf "$package_path" done