Publish npm Package #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish npm Package | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| publish-npm: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: zulu | |
| java-version: 17 | |
| cache: gradle | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.x" | |
| registry-url: "https://npm.pkg.github.com/" | |
| scope: "@towolabs" | |
| - name: Build CLI distribution | |
| run: ./gradlew :maestro-cli:installDist --no-daemon | |
| - name: Extract version from gradle.properties | |
| id: version | |
| run: | | |
| CLI_VERSION=$(grep -w "CLI_VERSION" maestro-cli/gradle.properties | cut -d'=' -f2) | |
| echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $CLI_VERSION" | |
| - name: Prepare npm package | |
| run: | | |
| # Create package directory | |
| mkdir -p npm-package | |
| # Copy bin and lib directories from gradle build output | |
| cp -r maestro-cli/build/install/maestro/bin npm-package/ | |
| cp -r maestro-cli/build/install/maestro/lib npm-package/ | |
| # Copy and update package.json with the correct version | |
| cat package.json | jq --arg version "${{ steps.version.outputs.CLI_VERSION }}" '.version = $version' > npm-package/package.json | |
| # Make the maestro binary executable | |
| chmod +x npm-package/bin/maestro | |
| # Display package contents for debugging | |
| echo "Package contents:" | |
| ls -la npm-package/ | |
| echo "Bin contents:" | |
| ls -la npm-package/bin/ | |
| echo "Package.json:" | |
| cat npm-package/package.json | |
| - name: Publish to GitHub Packages | |
| working-directory: npm-package | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |