From a9e3e8119554c4596e7cf8c82ffb53c38aac941f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 2 Apr 2026 17:29:11 -0500 Subject: [PATCH] Add build-apk, deploy-nsite, and publish-zapstore CI jobs with zapstore.yaml --- .gitlab-ci.yml | 179 +++++++++++++++++++++++++++++++++++++++++++++++++ zapstore.yaml | 39 +++++++++++ 2 files changed, 218 insertions(+) create mode 100644 zapstore.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca1a990d..0fc8a2c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,11 +3,19 @@ image: node:25 default: interruptible: true timeout: 1 minute + cache: + key: + files: + - package-lock.json + paths: + - node_modules/ stages: - test - deploy + - build - release + - publish test: stage: test @@ -34,9 +42,148 @@ pages: paths: - public +deploy-nsite: + stage: deploy + timeout: 10 minutes + rules: + - if: $CI_COMMIT_TAG + when: never + - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH + variables: + NSYTE_VERSION: "v0.24.1" + script: + # Build the web app + - npm ci + - npm run build + - cp dist/index.html dist/404.html + + # Download nsyte binary + - curl -fsSL "https://github.com/sandwichfarm/nsyte/releases/download/${NSYTE_VERSION}/nsyte-linux" -o /usr/local/bin/nsyte + - chmod +x /usr/local/bin/nsyte + + # Deploy to nsite via nsyte using the nbunksec credential + - >- + nsyte deploy ./dist + -i + --sec "$NSITE_NBUNKSEC" + --name shakespeare + --relays "wss://relay.ditto.pub,wss://relay.nsite.lol,wss://relay.dreamith.to,wss://relay.primal.net" + --servers "https://blossom.primal.net,https://blossom.ditto.pub,https://blossom.dreamith.to" + --fallback "/index.html" + --publish-server-list + --use-fallback-relays + --use-fallback-servers + +build-apk: + stage: build + image: eclipse-temurin:21-jdk + timeout: 15 minutes + needs: [] + rules: + - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + variables: + ANDROID_SDK_ROOT: /opt/android-sdk + ANDROID_HOME: /opt/android-sdk + before_script: + # Install system dependencies + - apt-get update -qq + - apt-get install -y -qq curl unzip > /dev/null + + # Install Node.js 22 + - curl -fsSL https://deb.nodesource.com/setup_22.x | bash - + - apt-get install -y -qq nodejs > /dev/null + - node --version + - npm --version + + # Install Android SDK command-line tools + - mkdir -p $ANDROID_SDK_ROOT/cmdline-tools + - curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o cmdline-tools.zip + - unzip -q cmdline-tools.zip -d $ANDROID_SDK_ROOT/cmdline-tools + - mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest + - export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH" + + # Accept licenses and install SDK components + - printf 'y\ny\ny\ny\ny\ny\ny\n' | sdkmanager --licenses > /dev/null 2>&1 || true + - sdkmanager --install "platforms;android-36" "build-tools;36.0.0" "platform-tools" > /dev/null + + # Write local.properties for Gradle + - echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties + + # Decode signing keystore and migrate JKS -> PKCS12 for Gradle compatibility + - echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > android/app/my-upload-key.jks + - keytool -importkeystore + -srckeystore android/app/my-upload-key.jks + -destkeystore android/app/my-upload-key.keystore + -deststoretype pkcs12 + -srcstorepass "$KEYSTORE_PASSWORD" + -deststorepass "$KEYSTORE_PASSWORD" + -srcalias upload + -destalias upload + -noprompt + - rm android/app/my-upload-key.jks + + # Write key.properties from CI/CD variables + - | + cat > android/key.properties << EOF + storePassword=$KEYSTORE_PASSWORD + keyPassword=$KEY_PASSWORD + keyAlias=upload + storeFile=my-upload-key.keystore + EOF + script: + # Extract semver version from git tag (e.g., v9.9.2 -> 9.9.2) + - TAG="${CI_COMMIT_TAG#v}" + - VERSION_NAME="${TAG}" + - VERSION_CODE="${CI_PIPELINE_IID}" + - echo "Building version $VERSION_NAME (code $VERSION_CODE) from tag $CI_COMMIT_TAG" + + # Stamp version into build.gradle + - sed -i "s/versionCode [0-9]*/versionCode ${VERSION_CODE}/" android/app/build.gradle + - sed -i "s/versionName \"[^\"]*\"/versionName \"${VERSION_NAME}\"/" android/app/build.gradle + + # Build web assets + - npm ci + - npx vite build -l error + - cp dist/index.html dist/404.html + + # Sync web assets to Capacitor Android project + - npx cap sync android + + # Build signed release APK + - cd android && chmod +x gradlew && ./gradlew assembleRelease bundleRelease && cd .. + + # Copy APK to a predictable artifact path + - mkdir -p artifacts + - cp android/app/build/outputs/apk/release/app-release.apk "artifacts/Shakespeare.apk" + - cp android/app/build/outputs/bundle/release/app-release.aab "artifacts/Shakespeare.aab" + - ls -lh artifacts/ + + # Upload to Generic Packages registry for a stable public download URL + - | + curl --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \ + --upload-file "artifacts/Shakespeare.apk" \ + "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/shakespeare/${CI_COMMIT_TAG}/Shakespeare-${CI_COMMIT_TAG}.apk" + - | + curl --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \ + --upload-file "artifacts/Shakespeare.aab" \ + "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/shakespeare/${CI_COMMIT_TAG}/Shakespeare-${CI_COMMIT_TAG}.aab" + + artifacts: + paths: + - artifacts/Shakespeare.apk + - artifacts/Shakespeare.aab + expire_in: 90 days + cache: + key: android-gradle + paths: + - android/.gradle/ + - .gradle/ + release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest + needs: + - build-apk rules: - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ script: @@ -54,3 +201,35 @@ release: tag_name: $CI_COMMIT_TAG name: $CI_COMMIT_TAG description: './release-notes.md' + assets: + links: + - name: Shakespeare-${CI_COMMIT_TAG}.apk + url: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/shakespeare/${CI_COMMIT_TAG}/Shakespeare-${CI_COMMIT_TAG}.apk + link_type: package + - name: Shakespeare-${CI_COMMIT_TAG}.aab + url: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/shakespeare/${CI_COMMIT_TAG}/Shakespeare-${CI_COMMIT_TAG}.aab + link_type: package + +publish-zapstore: + stage: publish + image: golang:1.24 + needs: + - build-apk + rules: + - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + variables: + SIGN_WITH: $ZAPSTORE_BUNKER_URL + script: + - go install github.com/zapstore/zsp@latest + + # Restore the persistent NIP-46 client key so the bunker recognizes us across CI runs. + # zsp stores client keys at ~/.config/zsp/bunker-keys/.key + - BUNKER_PUBKEY=$(echo "$ZAPSTORE_BUNKER_URL" | sed 's|bunker://||;s|?.*||') + - mkdir -p ~/.config/zsp/bunker-keys + - echo "$ZAPSTORE_CLIENT_KEY" > ~/.config/zsp/bunker-keys/${BUNKER_PUBKEY}.key + + - APK_PATH="artifacts/Shakespeare.apk" + - VERSION="${CI_COMMIT_TAG#v}" + - sed -i "2i release_source:\ ./${APK_PATH}" zapstore.yaml + - sed -i "2i version:\ ${VERSION}" zapstore.yaml + - zsp publish --quiet --skip-metadata --skip-preview zapstore.yaml diff --git a/zapstore.yaml b/zapstore.yaml new file mode 100644 index 00000000..4f70365c --- /dev/null +++ b/zapstore.yaml @@ -0,0 +1,39 @@ +repository: https://gitlab.com/soapbox-pub/shakespeare + +name: Shakespeare + +summary: Build custom apps with AI, right from your browser. + +description: | + Shakespeare is an open-source AI-powered app builder. Describe what you + want to build in natural language, and AI will help you create it — all + within your browser. + + Features: + - AI chat — build apps through conversation with AI assistants + - Live preview — see your app update in real time as you build + - Virtual filesystem — full project files stored in-browser via IndexedDB + - Git integration — version control with isomorphic-git, clone templates + - Nostr login — authenticate with your Nostr identity + - Multiple AI providers — configure OpenAI-compatible providers and API keys + - Project management — create, import, and manage multiple projects + - ZIP import — import existing projects from ZIP files + +tags: + - nostr + - ai + - development + - builder + +license: AGPL-3.0 + +website: https://shakespeare.diy + +icon: ./public/shakespeare-512x512.png + +images: [] + +release_notes: ./CHANGELOG.md + +metadata_sources: + - gitlab