diff --git a/.circleci/config.yml b/.circleci/config.yml index 5271235e..0a254ed0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,14 +29,6 @@ run_always: &run_always tags: only: /.*/ -# Only run on release -run_on_release: &run_on_release - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ - commands: attach_project: steps: @@ -204,29 +196,6 @@ jobs: path: ~/.maestro/tests destination: maestro-tests - release-to-npm: - executor: default - steps: - - checkout - - run: - name: Add npm registry auth key - command: | - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/project/.npmrc - npm config set scope $ORG_NAME - - - restore_cache: - keys: - - dependencies-{{ checksum "package.json" }} - - - run: - name: Install dependencies - command: | - yarn install - - - run: - name: Publish the package - command: npm publish - workflows: version: 2.1 build-and-test: @@ -265,18 +234,4 @@ workflows: # - lint # - typescript # - unit-tests - # - build-package - - - release-to-npm: - <<: *run_on_release - context: - - react-native-context - requires: - - install-dependencies - - lint - - typescript - - unit-tests - - build-package - # Temporarily removed e2e test dependencies - # - ios-e2e-test - # - android-e2e-test + # - build-package \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..9cd922ad --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,108 @@ +name: Release to npm + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: 'Tag to publish (e.g., 9.5.0)' + required: true + type: string + +jobs: + validate: + name: Validate Release + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name || github.event.inputs.tag }} + + - name: Extract and validate version + id: version + run: | + TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}" + VERSION="${TAG#v}" + + if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then + echo "Error: Invalid version format: $VERSION" + exit 1 + fi + + PKG_VERSION=$(node -p "require('./package.json').version") + if [ "$VERSION" != "$PKG_VERSION" ]; then + echo "Error: Tag version ($VERSION) does not match package.json version ($PKG_VERSION)" + exit 1 + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + + test: + name: Test + runs-on: ubuntu-latest + needs: validate + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name || github.event.inputs.tag }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22.14.0' + cache: 'yarn' + + - name: Enable Corepack + run: corepack enable + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint + run: yarn lint + + - name: TypeScript + run: yarn typescript + + - name: Unit tests + run: yarn test + + - name: Build package + run: yarn prepare + + publish: + name: Publish to npm + runs-on: ubuntu-latest + needs: [validate, test] + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name || github.event.inputs.tag }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22.14.0' + cache: 'yarn' + registry-url: 'https://registry.npmjs.org' + + - name: Enable Corepack + run: corepack enable + + - name: Install dependencies + run: yarn install --immutable + + - name: Build package + run: yarn prepare + + - name: Publish to npm + run: npm publish --access public