Skip to content

Commit 31a80e4

Browse files
committed
Initialize project with package.json and GitHub Actions workflow for npm package publishing
1 parent e2bbda1 commit 31a80e4

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

.github/workflows/publish-npm.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish npm Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-npm:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Java
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: zulu
22+
java-version: 17
23+
cache: gradle
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "20.x"
29+
registry-url: "https://npm.pkg.github.com/"
30+
scope: "@towolabs"
31+
32+
- name: Build CLI distribution
33+
run: ./gradlew :maestro-cli:installDist --no-daemon
34+
35+
- name: Extract version from gradle.properties
36+
id: version
37+
run: |
38+
CLI_VERSION=$(grep -w "CLI_VERSION" maestro-cli/gradle.properties | cut -d'=' -f2)
39+
echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_OUTPUT
40+
echo "Extracted version: $CLI_VERSION"
41+
42+
- name: Prepare npm package
43+
run: |
44+
# Create package directory
45+
mkdir -p npm-package
46+
47+
# Copy bin and lib directories from gradle build output
48+
cp -r maestro-cli/build/install/maestro/bin npm-package/
49+
cp -r maestro-cli/build/install/maestro/lib npm-package/
50+
51+
# Copy and update package.json with the correct version
52+
cat package.json | jq --arg version "${{ steps.version.outputs.CLI_VERSION }}" '.version = $version' > npm-package/package.json
53+
54+
# Make the maestro binary executable
55+
chmod +x npm-package/bin/maestro
56+
57+
# Display package contents for debugging
58+
echo "Package contents:"
59+
ls -la npm-package/
60+
echo "Bin contents:"
61+
ls -la npm-package/bin/
62+
echo "Package.json:"
63+
cat npm-package/package.json
64+
65+
- name: Publish to GitHub Packages
66+
working-directory: npm-package
67+
run: npm publish
68+
env:
69+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "@towolabs/maestro",
3+
"version": "0.0.1",
4+
"description": "The easiest way to automate UI testing for your mobile app",
5+
"license": "Apache-2.0",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/towolabs/Maestro.git"
9+
},
10+
"homepage": "https://maestro.mobile.dev",
11+
"bugs": {
12+
"url": "https://github.com/towolabs/Maestro/issues"
13+
},
14+
"bin": {
15+
"maestro": "./bin/maestro"
16+
},
17+
"files": [
18+
"bin",
19+
"lib"
20+
],
21+
"os": [
22+
"darwin",
23+
"linux",
24+
"win32"
25+
],
26+
"engines": {
27+
"node": ">=18"
28+
},
29+
"keywords": [
30+
"mobile",
31+
"testing",
32+
"automation",
33+
"ios",
34+
"android",
35+
"ui-testing",
36+
"e2e",
37+
"end-to-end"
38+
],
39+
"publishConfig": {
40+
"registry": "https://npm.pkg.github.com"
41+
}
42+
}

0 commit comments

Comments
 (0)