when: - event: [push, pull_request, manual] variables: - &node_image "node:22-alpine" steps: install: image: *node_image commands: - corepack enable - npm ci lint: image: *node_image commands: - npm run lint depends_on: - install typecheck: image: *node_image commands: - npm run typecheck depends_on: - install format-check: image: *node_image commands: - npm run format:check depends_on: - install security-audit: image: *node_image commands: - npm audit --audit-level=high depends_on: - install test: image: *node_image commands: - npm run test:coverage depends_on: - install build: image: *node_image commands: - npm run build depends_on: - lint - typecheck - format-check - security-audit - test publish: image: *node_image environment: GITEA_TOKEN: from_secret: gitea_token commands: - npm run build - | echo "//git.mosaicstack.dev/api/packages/mosaic/npm/:_authToken=$$GITEA_TOKEN" > .npmrc echo "@mosaicstack:registry=https://git.mosaicstack.dev/api/packages/mosaic/npm/" >> .npmrc - | CURRENT=$(node -p "require('./package.json').version") PUBLISHED=$(npm view @mosaicstack/telemetry-client version 2>/dev/null || echo "0.0.0") if [ "$$CURRENT" = "$$PUBLISHED" ]; then echo "Version $$CURRENT already published, skipping" exit 0 fi echo "Publishing $$CURRENT (was $$PUBLISHED)" npm publish --access public when: - branch: [main, develop] event: [push, manual, tag] depends_on: - build link-package: image: alpine:3 environment: GITEA_TOKEN: from_secret: gitea_token commands: - apk add --no-cache curl - | set -e PKG="%40mosaicstack%2Ftelemetry-client" for attempt in 1 2 3; do STATUS=$$(curl -s -o /tmp/link-response.txt -w "%{http_code}" -X POST \ -H "Authorization: token $$GITEA_TOKEN" \ "https://git.mosaicstack.dev/api/v1/packages/mosaic/npm/$$PKG/-/link/telemetry-client-js") if [ "$$STATUS" = "201" ] || [ "$$STATUS" = "204" ]; then echo "Package linked to repository" exit 0 elif [ "$$STATUS" = "400" ]; then echo "Package already linked (OK)" exit 0 elif [ $$attempt -lt 3 ]; then echo "Status $$STATUS, retrying in 5s (attempt $$attempt/3)..." sleep 5 else echo "FAILED to link package (status $$STATUS)" cat /tmp/link-response.txt exit 1 fi done when: - branch: [main, develop] event: [push, manual, tag] depends_on: - publish