Skip to content

Commit d26eb53

Browse files
authored
add auto publish (#40)
1 parent 1f427f9 commit d26eb53

File tree

2 files changed

+54
-16
lines changed

2 files changed

+54
-16
lines changed

.circleci/config.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
22
jobs:
3-
test:
3+
build:
44
machine: true
55
working_directory: ~/project
66
steps:
@@ -9,25 +9,37 @@ jobs:
99
name: Build docker image
1010
command: |
1111
docker build -t react-native-community/react-native .
12-
- run:
13-
name: Test Avd
14-
command: |
15-
docker run --rm --name rn-build -v $PWD:/pwd -w /pwd react-native-community/react-native bash -c \
16-
"chmod +x ./test-avd.sh && ./test-avd.sh"
17-
- run:
18-
name: Test react-native repo
19-
command: |
20-
git clone https://github.com/facebook/react-native --depth=1
21-
cd react-native
22-
docker run --rm --name rn-build -v $PWD:/pwd -w /pwd react-native-community/react-native bash -c \
23-
"yarn install && ./gradlew RNTester:android:app:assembleRelease && ./scripts/circleci/buck_fetch.sh"
2412
- run:
2513
name: Docker info
2614
command: |
27-
docker run --rm --name rn-env react-native-community/react-native bash -c "npm i -g envinfo && envinfo"
15+
docker run --rm --name rn-env react-native-community/react-native bin/sh -c "npx envinfo"
16+
test:
17+
- run:
18+
name: Test
19+
command: |
20+
git clone https://github.com/facebook/react-native --depth=1
21+
cd react-native
22+
docker run --rm --name rn-build -v $PWD:/pwd -w /pwd react-native-community/react-native /bin/sh -c \
23+
"yarn install && ./gradlew RNTester:android:app:assembleRelease && ./scripts/circleci/buck_fetch.sh"
24+
deploy:
25+
- run:
26+
name: Deploy docker
27+
command: |
28+
source ~/.bashrc
29+
nvm i node
30+
node publish_docker.js
2831
2932
workflows:
3033
version: 2
31-
perfs:
34+
main:
3235
jobs:
33-
- test
36+
- build
37+
- test:
38+
requires:
39+
- build
40+
- deploy:
41+
requires:
42+
- build
43+
filters:
44+
branches:
45+
only: master

publish_docker.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const execSync = require("child_process").execSync;
2+
3+
function publishDocker() {
4+
const now = new Date()
5+
const repo = `reactnativecommunity/react-native-android`
6+
const finaltag = `${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()}`
7+
const cmd =`
8+
docker login -u ${process.env.DOCKER_USER} -p ${process.env.DOCKER_PASS}
9+
docker build -t ${repo}:${finaltag} .
10+
docker tag ${repo}:${finaltag} ${repo}
11+
docker push ${repo}:${finaltag}
12+
docker push ${repo}
13+
`
14+
cmd.trim().split("\n").map(i => {
15+
const cmd = i.trim();
16+
if (cmd) {
17+
if (!cmd.includes('login')) {
18+
console.log(cmd);
19+
}
20+
const output = execSync(cmd)
21+
console.log(output.toString());
22+
}
23+
})
24+
}
25+
26+
publishDocker()

0 commit comments

Comments
 (0)