Skip to content

Commit

Permalink
Fix publish workflow
Browse files Browse the repository at this point in the history
Signed-off-by: paulober <[email protected]>
  • Loading branch information
paulober committed Sep 4, 2024
1 parent a5c0ad7 commit e4502b8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 43 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
}),
Expand Down
59 changes: 31 additions & 28 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e4502b8

Please sign in to comment.