Skip to content

Commit a79673d

Browse files
authored
chore: add ci and automatic publish (#1766)
Also updates the changelog up to 8.5.0
1 parent 1a928e4 commit a79673d

File tree

8 files changed

+537
-1
lines changed

8 files changed

+537
-1
lines changed

.github/workflows/npm_release.yml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
NPM_TAG: "next"
10+
EMULATOR_NAME: "runtime-emu"
11+
NDK_VERSION: r21b
12+
ANDROID_API: 29
13+
ANDROID_ABI: x86_64
14+
NDK_ARCH: darwin-x86_64
15+
16+
17+
jobs:
18+
build:
19+
name: Build
20+
runs-on: macos-latest
21+
outputs:
22+
npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }}
23+
npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }}
24+
steps:
25+
- uses: actions/checkout@v3
26+
with:
27+
fetch-depth: 0
28+
submodules: true
29+
- uses: actions/setup-node@v3
30+
with:
31+
node-version: 18
32+
registry-url: "https://registry.npmjs.org"
33+
- uses: actions/setup-java@v3
34+
with:
35+
distribution: "temurin"
36+
java-version: "17"
37+
cache: gradle
38+
- name: Setup Android SDK
39+
uses: android-actions/setup-android@v2
40+
- name: Homebrew dependencies
41+
run: |
42+
brew install wget
43+
- name: Setup NDK
44+
run: |
45+
echo "y" | sdkmanager "cmake;3.6.4111459"
46+
wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
47+
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
48+
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
49+
rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip
50+
export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
51+
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
52+
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
53+
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
54+
- name: Install Dependencies
55+
run: |
56+
npm install
57+
npm install --prefix ./test-app/tools
58+
- name: Get Current Version
59+
run: |
60+
NPM_VERSION=$(node -e "console.log(require('./package.json').version);")
61+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
62+
- name: Bump version for dev release
63+
if: ${{ !contains(github.ref, 'refs/tags/') }}
64+
run: |
65+
NPM_VERSION=$(node ./scripts/get-next-version.js)
66+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
67+
npm version $NPM_VERSION --no-git-tag-version
68+
- name: Output NPM Version and tag
69+
id: npm_version_output
70+
run: |
71+
NPM_TAG=$(node ./scripts/get-npm-tag.js)
72+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT
73+
echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT
74+
- name: Build npm package
75+
run: ./gradlew -PgitCommitVersion=${{ github.sha }} -PnoCCache --stacktrace
76+
- name: Upload npm package artifact
77+
uses: actions/upload-artifact@v3
78+
with:
79+
name: npm-package
80+
path: dist/nativescript-android-${{steps.npm_version_output.outputs.NPM_VERSION}}.tgz
81+
test:
82+
name: Test
83+
runs-on: macos-latest
84+
needs: build
85+
steps:
86+
- uses: actions/checkout@v3
87+
with:
88+
submodules: true
89+
- uses: actions/setup-node@v3
90+
with:
91+
node-version: 18
92+
registry-url: "https://registry.npmjs.org"
93+
- uses: actions/setup-java@v3
94+
with:
95+
distribution: "temurin"
96+
java-version: "17"
97+
cache: gradle
98+
- name: Setup Android SDK
99+
uses: android-actions/setup-android@v2
100+
- name: Homebrew dependencies
101+
run: |
102+
brew install wget
103+
- name: Setup NDK
104+
run: |
105+
echo "y" | sdkmanager "cmake;3.6.4111459"
106+
wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
107+
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
108+
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
109+
rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip
110+
export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
111+
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
112+
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
113+
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
114+
- name: Install Dependencies
115+
run: |
116+
npm install
117+
npm install --prefix ./test-app/tools
118+
- name: SBG tests
119+
run: ./gradlew runSbgTests --stacktrace
120+
- name: Run unit tests
121+
uses: ReactiveCircus/android-emulator-runner@v2
122+
with:
123+
api-level: ${{env.ANDROID_API}}
124+
# this is needed on API 30+
125+
#target: google_apis
126+
arch: ${{env.ANDROID_ABI}}
127+
script: ./gradlew runtestsAndVerifyResults --stacktrace
128+
publish:
129+
runs-on: ubuntu-latest
130+
needs:
131+
- build
132+
- test
133+
permissions:
134+
contents: read
135+
id-token: write
136+
env:
137+
NPM_VERSION: ${{needs.build.outputs.npm_version}}
138+
NPM_TAG: ${{needs.build.outputs.npm_tag}}
139+
steps:
140+
- uses: actions/setup-node@v3
141+
with:
142+
node-version: 18
143+
registry-url: 'https://registry.npmjs.org'
144+
- uses: actions/download-artifact@v3
145+
with:
146+
name: npm-package
147+
path: dist
148+
- name: Publish package
149+
run: |
150+
echo "Publishing @nativescript/android@$NPM_VERSION to NPM with tag $NPM_TAG..."
151+
npm publish ./dist/nativescript-android-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --provenance
152+
env:
153+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
154+
github-release:
155+
runs-on: ubuntu-latest
156+
# only runs on tagged commits
157+
if: ${{ contains(github.ref, 'refs/tags/') }}
158+
permissions:
159+
contents: write
160+
needs:
161+
- build
162+
- test
163+
env:
164+
NPM_VERSION: ${{needs.build.outputs.npm_version}}
165+
steps:
166+
- uses: actions/checkout@v3
167+
with:
168+
fetch-depth: 0
169+
- uses: actions/setup-node@v3
170+
with:
171+
node-version: 18
172+
- name: Setup
173+
run: npm install
174+
- uses: actions/download-artifact@v3
175+
with:
176+
name: npm-package
177+
path: dist
178+
- name: Partial Changelog
179+
run: npx conventional-changelog -p angular -r2 > body.md
180+
- uses: ncipollo/release-action@v1
181+
with:
182+
artifacts: "dist/nativescript-android-*.tgz"
183+
bodyFile: "body.md"

.github/workflows/pull_request.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
on:
2+
pull_request:
3+
4+
env:
5+
NPM_TAG: "pr"
6+
EMULATOR_NAME: "runtime-emu"
7+
NDK_VERSION: r21b
8+
ANDROID_API: 29
9+
ANDROID_ABI: x86_64
10+
NDK_ARCH: darwin-x86_64
11+
12+
13+
jobs:
14+
build:
15+
name: Build
16+
runs-on: macos-latest
17+
outputs:
18+
npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }}
19+
npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
submodules: true
25+
- uses: actions/setup-node@v3
26+
with:
27+
node-version: 18
28+
registry-url: "https://registry.npmjs.org"
29+
- uses: actions/setup-java@v3
30+
with:
31+
distribution: "temurin"
32+
java-version: "17"
33+
cache: gradle
34+
- name: Setup Android SDK
35+
uses: android-actions/setup-android@v2
36+
- name: Homebrew dependencies
37+
run: |
38+
brew install wget
39+
- name: Setup NDK
40+
run: |
41+
echo "y" | sdkmanager "cmake;3.6.4111459"
42+
wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
43+
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
44+
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
45+
rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip
46+
export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
47+
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
48+
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
49+
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
50+
- name: Install Dependencies
51+
run: |
52+
npm install
53+
npm install --prefix ./test-app/tools
54+
- name: Get Current Version
55+
run: |
56+
NPM_VERSION=$(node -e "console.log(require('./package.json').version);")
57+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
58+
- name: Bump version for dev release
59+
if: ${{ !contains(github.ref, 'refs/tags/') }}
60+
run: |
61+
NPM_VERSION=$(node ./scripts/get-next-version.js)
62+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
63+
npm version $NPM_VERSION --no-git-tag-version
64+
- name: Output NPM Version and tag
65+
id: npm_version_output
66+
run: |
67+
NPM_TAG=$(node ./scripts/get-npm-tag.js)
68+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT
69+
echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT
70+
- name: Build npm package
71+
run: ./gradlew -PgitCommitVersion=${{ github.sha }} -PnoCCache --stacktrace
72+
- name: Upload npm package artifact
73+
uses: actions/upload-artifact@v3
74+
with:
75+
name: npm-package
76+
path: dist/nativescript-android-${{steps.npm_version_output.outputs.NPM_VERSION}}.tgz
77+
test:
78+
name: Test
79+
runs-on: macos-latest
80+
needs: build
81+
steps:
82+
- uses: actions/checkout@v3
83+
with:
84+
submodules: true
85+
- uses: actions/setup-node@v3
86+
with:
87+
node-version: 18
88+
registry-url: "https://registry.npmjs.org"
89+
- uses: actions/setup-java@v3
90+
with:
91+
distribution: "temurin"
92+
java-version: "17"
93+
cache: gradle
94+
- name: Setup Android SDK
95+
uses: android-actions/setup-android@v2
96+
- name: Homebrew dependencies
97+
run: |
98+
brew install wget
99+
- name: Setup NDK
100+
run: |
101+
echo "y" | sdkmanager "cmake;3.6.4111459"
102+
wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
103+
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
104+
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
105+
rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip
106+
export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
107+
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
108+
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
109+
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
110+
- name: Install Dependencies
111+
run: |
112+
npm install
113+
npm install --prefix ./test-app/tools
114+
- name: SBG tests
115+
run: ./gradlew runSbgTests --stacktrace
116+
- name: Run unit tests
117+
uses: ReactiveCircus/android-emulator-runner@v2
118+
with:
119+
api-level: ${{env.ANDROID_API}}
120+
# this is needed on API 30+
121+
#target: google_apis
122+
arch: ${{env.ANDROID_ABI}}
123+
script: ./gradlew runtestsAndVerifyResults --stacktrace

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
message="release: %s"

0 commit comments

Comments
 (0)