跳到主要内容

Plugin Packaging

This document introduces how to build and package the plugin code into an executable ZIP file, including build configuration, build steps, and package structure explanation.

The Atomgit Actions plugin needs to execute a build command to generate executable js files, which can be directly referenced and executed in the pipeline. The build is orchestrated through the configuration of package.json.

Build Configuration Example (TS Project)

{
"name": "gitcode-actions-plugin-demo",
"version": "1.0.11",
"description": "demo plugin",
"main": "main.js",
"scripts": {
"build": "tsc",
"package-main": "ncc build lib/main.js",
"package-stop": "ncc build lib/stop.js -o dist/stop && move dist\\stop\\main.js dist\\stop.js && rmdir /S /Q dist\\stop",
"test": "jest",
"all": "npm run build && npm run package-main && npm run package-stop",
"dev": "npm run build && npm run package"
},
"devDependencies": {
"@actions/core": "^1.11.1",
"@types/node": "^22.7.6"
},
"dependencies": {
"axios": "^1.7.7"
}
}

Build Steps

  1. Compile: npm run build — Execute TypeScript compilation
  2. Package: npm run package-main and npm run package-stop — Package into a single file using ncc
  3. One-click Build: npm run all — Compile + Package