diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 18fcea0..93bce5e 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -1,16 +1,29 @@ name: Publish to npm +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + on: - push: - tags: - - 'v*' workflow_dispatch: + inputs: + deployment_mode: + description: 'Choose dry-run to validate or publish for real deployment.' + required: true + default: dry-run + type: choice + options: + - dry-run + - publish + tag: + description: "Optional tag override (example: v1.1.4). Leave empty to use v." + required: false + type: string jobs: publish: runs-on: ubuntu-latest permissions: - contents: read + contents: write id-token: write steps: @@ -23,11 +36,29 @@ jobs: node-version: 24 registry-url: 'https://registry.npmjs.org' + - name: Resolve release tag + id: release_tag + run: | + if [ -n "${{ inputs.tag }}" ]; then + TAG="${{ inputs.tag }}" + else + VERSION="$(node -p "require('./package.json').version")" + TAG="v${VERSION}" + fi + + if [[ ! "$TAG" =~ ^v[0-9].* ]]; then + echo "Resolved tag must start with 'v' (example: v1.1.4), got: $TAG" + exit 1 + fi + + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + echo "Using release tag: $TAG" + - name: Enable Corepack run: corepack enable - name: Install dependencies - run: yarn install --immutable + run: yarn install --no-immutable - name: Typecheck run: yarn typecheck @@ -38,5 +69,29 @@ jobs: - name: Build package run: yarn prepare + - name: Publish to npm (dry-run) + if: ${{ inputs.deployment_mode == 'dry-run' }} + run: npm publish --provenance --access public --dry-run + - name: Publish to npm + if: ${{ inputs.deployment_mode == 'publish' }} run: npm publish --provenance --access public + + - name: Ensure git tag exists + if: ${{ inputs.deployment_mode == 'publish' }} + run: | + TAG="${{ steps.release_tag.outputs.tag }}" + git fetch --tags + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "Tag $TAG already exists." + else + git tag "$TAG" + git push origin "$TAG" + fi + + - name: Create GitHub release + if: ${{ inputs.deployment_mode == 'publish' }} + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.release_tag.outputs.tag }} + generate_release_notes: true diff --git a/example/src/App.tsx b/example/src/App.tsx index f8c57f8..c1d972c 100755 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -19,7 +19,6 @@ import HomeScreen from './HomeScreen'; import { Routes } from './Routes'; import { MappIntelligencePlugin, - ExceptionType, LogLevel, } from 'mapp-intelligence-reactnative-plugin'; import FetchExample from './FetchExample'; diff --git a/example/src/FetchExample.tsx b/example/src/FetchExample.tsx index 0a07cea..6ec05eb 100644 --- a/example/src/FetchExample.tsx +++ b/example/src/FetchExample.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Alert, FlatList, SafeAreaView } from 'react-native'; +import { FlatList, SafeAreaView } from 'react-native'; import { DefaultStyles, Dialog, MappButton } from './components/MappComponents'; const FetchExample = ()=>{ diff --git a/package.json b/package.json index 858bee5..daf5a1a 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mapp-intelligence-reactnative-plugin", - "version": "1.1.3", + "version": "1.1.2", "description": "The MappIntelligence SDK allows you to track user activities, screen flow and media usage for an App. All data is send to the MappIntelligence tracking system for further analysis.", "main": "lib/commonjs/index", "module": "lib/module/index", @@ -29,7 +29,7 @@ "example": "yarn workspace react-native-mappinteligence-plugin-example", "install:high-mem": "NODE_OPTIONS=--max-old-space-size=8192 yarn install", "test": "jest", - "typecheck": "tsc --noEmit", + "typecheck": "tsc --noEmit -p tsconfig.build.json", "lint": "eslint \"**/*.{js,ts,tsx}\"", "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib", "prepare": "bob build",