|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +env: |
| 9 | + NPM_TAG: "next" |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build |
| 14 | + runs-on: macos-12 |
| 15 | + outputs: |
| 16 | + npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }} |
| 17 | + npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }} |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + - name: LLVM cache |
| 23 | + uses: actions/cache@v3 |
| 24 | + with: |
| 25 | + path: ./llvm |
| 26 | + key: ${{ hashFiles('download_llvm.sh') }} |
| 27 | + - uses: actions/setup-node@v3 |
| 28 | + with: |
| 29 | + node-version: 18 |
| 30 | + - name: Install Python |
| 31 | + uses: actions/setup-python@v4 |
| 32 | + with: |
| 33 | + python-version: "3" |
| 34 | + - name: Install Dependencies |
| 35 | + run: | |
| 36 | + npm install |
| 37 | + python3 -m pip install --upgrade pip six |
| 38 | + brew install cmake |
| 39 | + [ ! -f /usr/local/bin/cmake ] && ln -s /usr/local/bin/cmake $(which cmake) || true |
| 40 | + - name: Get Current Version |
| 41 | + run: | |
| 42 | + NPM_VERSION=$(node -e "console.log(require('./package.json').version);") |
| 43 | + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV |
| 44 | + - name: Bump version for dev release |
| 45 | + if: ${{ !contains(github.ref, 'refs/tags/') }} |
| 46 | + run: | |
| 47 | + NPM_VERSION=$(node ./scripts/get-next-version.js) |
| 48 | + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV |
| 49 | + npm version $NPM_VERSION --no-git-tag-version |
| 50 | + - name: Output NPM Version and tag |
| 51 | + id: npm_version_output |
| 52 | + run: | |
| 53 | + NPM_TAG=$(node ./scripts/get-npm-tag.js) |
| 54 | + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT |
| 55 | + echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT |
| 56 | + - name: Build |
| 57 | + run: npm run build |
| 58 | + - name: Upload npm package artifact |
| 59 | + uses: actions/upload-artifact@v3 |
| 60 | + with: |
| 61 | + name: npm-package |
| 62 | + path: dist/nativescript-ios-${{env.NPM_VERSION}}.tgz |
| 63 | + - name: Upload dSYMs artifact |
| 64 | + uses: actions/upload-artifact@v3 |
| 65 | + with: |
| 66 | + name: NativeScript-dSYMs |
| 67 | + path: dist/dSYMs |
| 68 | + test: |
| 69 | + name: Test |
| 70 | + runs-on: macos-12 |
| 71 | + needs: build |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v3 |
| 74 | + - name: LLVM cache |
| 75 | + uses: actions/cache@v3 |
| 76 | + with: |
| 77 | + path: ./llvm |
| 78 | + key: ${{ hashFiles('download_llvm.sh') }} |
| 79 | + - uses: actions/setup-node@v3 |
| 80 | + with: |
| 81 | + node-version: 18 |
| 82 | + - name: Install Python |
| 83 | + uses: actions/setup-python@v4 |
| 84 | + with: |
| 85 | + python-version: "3" |
| 86 | + - name: Install Dependencies |
| 87 | + run: | |
| 88 | + npm install |
| 89 | + python3 -m pip install --upgrade pip six |
| 90 | + brew install cmake |
| 91 | + [ ! -f /usr/local/bin/cmake ] && ln -s /usr/local/bin/cmake $(which cmake) || true |
| 92 | + brew install chargepoint/xcparse/xcparse |
| 93 | + npm install -g @edusperoni/junit-cli-report-viewer verify-junit-xml |
| 94 | + - name: Prepare |
| 95 | + run: npm run setup-ci |
| 96 | + - name: Xcode Tests |
| 97 | + uses: nick-fields/retry@v2 |
| 98 | + # try to run the tests with xcpretty. If it fails then try again without xcpretty twice for better log output |
| 99 | + # the xcode tests are a bit flaky and they should never fail on this step, as this step only collects the JS test results as junit xml |
| 100 | + with: |
| 101 | + timeout_minutes: 20 |
| 102 | + max_attempts: 3 |
| 103 | + command: set -o pipefail && xcodebuild -project v8ios.xcodeproj -scheme TestRunner -resultBundlePath $HOME/test_results -destination platform\=iOS\ Simulator,OS\=16.2,name\=iPhone\ 14\ Pro\ Max build test | xcpretty |
| 104 | + on_retry_command: rm -rf $HOME/test_results* |
| 105 | + new_command_on_retry: xcodebuild -project v8ios.xcodeproj -scheme TestRunner -resultBundlePath $HOME/test_results -destination platform\=iOS\ Simulator,OS\=16.2,name\=iPhone\ 14\ Pro\ Max build test |
| 106 | + - name: Validate Test Results |
| 107 | + run: | |
| 108 | + xcparse attachments $HOME/test_results.xcresult $HOME/test-out |
| 109 | + find $HOME/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer |
| 110 | + find $HOME/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml |
| 111 | + publish: |
| 112 | + runs-on: ubuntu-latest |
| 113 | + needs: |
| 114 | + - build |
| 115 | + - test |
| 116 | + env: |
| 117 | + NPM_VERSION: ${{needs.build.outputs.npm_version}} |
| 118 | + NPM_TAG: ${{needs.build.outputs.npm_tag}} |
| 119 | + steps: |
| 120 | + - uses: actions/setup-node@v3 |
| 121 | + with: |
| 122 | + node-version: 18 |
| 123 | + - uses: actions/download-artifact@v3 |
| 124 | + with: |
| 125 | + name: npm-package |
| 126 | + path: dist |
| 127 | + - name: Publish package |
| 128 | + run: | |
| 129 | + echo "Publishing @nativescript/ios@$NPM_VERSION to NPM with tag $NPM_TAG..." |
| 130 | + npm publish ./dist/nativescript-ios-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --provenance |
| 131 | + env: |
| 132 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} |
| 133 | + github-release: |
| 134 | + runs-on: ubuntu-latest |
| 135 | + # only runs on tagged commits |
| 136 | + if: ${{ contains(github.ref, 'refs/tags/') }} |
| 137 | + permissions: |
| 138 | + contents: write |
| 139 | + needs: |
| 140 | + - build |
| 141 | + - test |
| 142 | + env: |
| 143 | + NPM_VERSION: ${{needs.build.outputs.npm_version}} |
| 144 | + steps: |
| 145 | + - uses: actions/setup-node@v3 |
| 146 | + with: |
| 147 | + node-version: 18 |
| 148 | + - name: Setup |
| 149 | + run: npm install |
| 150 | + - uses: actions/download-artifact@v3 |
| 151 | + with: |
| 152 | + name: npm-package |
| 153 | + path: dist |
| 154 | + - uses: actions/download-artifact@v3 |
| 155 | + with: |
| 156 | + name: NativeScript-dSYMs |
| 157 | + path: dist |
| 158 | + - name: Partial Changelog |
| 159 | + run: npx conventional-changelog -p angular -r2 > body.md |
| 160 | + - uses: ncipollo/release-action@v1 |
| 161 | + with: |
| 162 | + artifacts: "dist/nativescript-ios-*.tgz,dist/dSYMs/*" |
| 163 | + bodyFile: "body.md" |
0 commit comments