diff --git a/.github/actions/setup-node-yarn/action.yml b/.github/actions/setup-node-yarn/action.yml new file mode 100644 index 0000000..6e550cc --- /dev/null +++ b/.github/actions/setup-node-yarn/action.yml @@ -0,0 +1,23 @@ +name: 'Setup Project' +description: 'Checkout code, setup Node.js, enable Yarn, and install dependencies' + +runs: + using: 'composite' + steps: + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version-file: '.nvmrc' + cache: yarn + + - name: Enable corepack + shell: bash + run: corepack enable + + - name: Install dependencies + shell: bash + run: yarn install --immutable + + - name: Prepare package + shell: bash + run: yarn prepare diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml new file mode 100644 index 0000000..4dd7727 --- /dev/null +++ b/.github/workflows/build-android.yml @@ -0,0 +1,32 @@ +name: Build Android Example + +on: + workflow_call: + +jobs: + build-android-example: + name: Build Android Example + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd + + - name: Setup Project + uses: ./.github/actions/setup-node-yarn + + - name: Setup Java + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e + with: + distribution: 'zulu' + java-version: '17' + + - name: Setup Android SDK + uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 + + - name: Install NDK + run: echo "y" | ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;27.1.12297006" + + - name: Build with Gradle + run: ./gradlew assembleDebug + working-directory: example/android \ No newline at end of file diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml new file mode 100644 index 0000000..52aa156 --- /dev/null +++ b/.github/workflows/build-ios.yml @@ -0,0 +1,57 @@ +name: Build iOS Example + +on: + workflow_call: + +jobs: + build-ios-example: + name: Build iOS Example + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd + + - name: Setup Project + uses: ./.github/actions/setup-node-yarn + + - name: Setup Xcode + run: sudo xcode-select -s /Applications/Xcode_26.1.app + + - name: Setup Ruby + uses: ruby/setup-ruby@d697be2f83c6234b20877c3b5eac7a7f342f0d0c + with: + ruby-version: '3.2' + bundler-cache: true + working-directory: example/ios + + - name: Cache CocoaPods + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 + with: + path: | + example/ios/Pods + ~/Library/Caches/CocoaPods + ~/.cocoapods + key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + + - name: Install CocoaPods + working-directory: example/ios + run: | + bundle install + bundle exec pod install + + - name: Build iOS example for simulator + working-directory: example/ios + run: | + xcodebuild \ + -workspace MendixNativeExample.xcworkspace \ + -scheme MendixNativeExample \ + -configuration Debug \ + -sdk iphonesimulator \ + -destination 'platform=iOS Simulator,name=iPhone 17,OS=latest' \ + -derivedDataPath build \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO \ + build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c2d2bf..065c669 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,30 +4,16 @@ on: pull_request: jobs: - lint-and-build: - name: Lint, Type Check & Build - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd - - - name: Setup Node - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 - with: - node-version-file: '.nvmrc' - - - name: Enable corepack - run: corepack enable - - - name: Install dependencies - run: yarn install --immutable - - - name: Type check - run: yarn typecheck - - - name: Lint check - run: yarn lint - - - name: Build - run: yarn prepare + lint: + name: Lint + uses: ./.github/workflows/lint.yml + + build-android: + name: Build Android + needs: lint + uses: ./.github/workflows/build-android.yml + + build-ios: + name: Build iOS + needs: lint + uses: ./.github/workflows/build-ios.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..74f69ee --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +name: Lint + +on: + workflow_call: + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd + + - name: Setup Project + uses: ./.github/actions/setup-node-yarn + + - name: Type check + run: yarn typecheck + + - name: Lint check + run: yarn lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27a474c..30e91b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,13 +26,21 @@ jobs: with: fetch-depth: 0 - - name: Setup Node - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 - with: - node-version-file: '.nvmrc' + - name: Setup Project + uses: ./.github/actions/setup-node-yarn - - name: Enable corepack - run: corepack enable + - name: Extract release notes from Unreleased section + id: changelog + run: | + NOTES=$(awk '/## \[Unreleased\]/ {flag=1; next} /^## \[/ {flag=0} flag && NF {print}' CHANGELOG.md) + if [ -z "$NOTES" ] || [ -z "$(echo "$NOTES" | tr -d '[:space:]')" ]; then + echo "Error: No release notes found in the [Unreleased] section of CHANGELOG.md" + echo "Please add release notes before creating a release." + exit 1 + fi + echo "notes<> $GITHUB_OUTPUT + echo "$NOTES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT - name: Bump version and update CHANGELOG id: bump @@ -41,18 +49,18 @@ jobs: echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT sed -i "s/## \[Unreleased\]/## [Unreleased]\n\n## [$NEW_VERSION] - $(date +%Y-%m-%d)/" CHANGELOG.md - - name: Extract release notes - id: changelog + - name: Check if release already exists run: | - NOTES=$(awk '/## \[Unreleased\]/ {flag=1; next} /^## \[/ {flag=0} flag {print}' CHANGELOG.md) - echo "notes<> $GITHUB_OUTPUT - echo "$NOTES" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.bump.outputs.version }}$"; then + echo "Error: Release tag ${{ steps.bump.outputs.version }} already exists" + echo "Please check existing releases or use a different version bump type." + exit 1 + fi - name: Build and pack id: pack run: | - yarn install + yarn install --immutable yarn prepare yarn pack --filename mendix-native-${{ steps.bump.outputs.version }}.tgz echo "tgz=mendix-native-${{ steps.bump.outputs.version }}.tgz" >> $GITHUB_OUTPUT