diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..77622997b --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,98 @@ +# -*- yaml -*- +version: 2.1 +orbs: + go-module: timakin/go-module@0.3.0 + sixrs-gke: sixriversystems/sixrs-gke@0.1.1 +jobs: + build-amd64: + docker: + - image: docker:18.09.9-git + steps: + - checkout + - setup_remote_docker + - run: + command: docker build -t amd64 -f amd64.dockerfile . + no_output_timeout: 3600 + - run: docker run --name temp-container amd64 /bin/true + - run: docker cp temp-container:/@6river/ . + - run: docker cp temp-container:/target_path.txt . + - run: docker cp temp-container:/binary_path.txt . + - run: docker rm temp-container + - run: ls -la + - persist_to_workspace: + root: ./ + paths: + - target_path.txt + - binary_path.txt + - '@6river' + build-arm64: + docker: + - image: docker:18.09.9-git + steps: + - checkout + - setup_remote_docker + - run: + command: docker build -t arm64 -f arm64.dockerfile . + no_output_timeout: 3600 + - run: docker run --name temp-container arm64 /bin/true + - run: docker cp temp-container:/@6river/ . + - run: docker rm temp-container + - run: ls -la + - persist_to_workspace: + root: ./ + paths: + - '@6river' + upload: + docker: + - image: google/cloud-sdk:alpine + steps: + - attach_workspace: + at: . + - run: ls -la + - run: + name: Activate gcloud + command: | + echo "${CLIENT_SECRET}" | base64 -d > /tmp/client-secret.json + gcloud auth activate-service-account --key-file /tmp/client-secret.json + - run: + name: Upload to gcloud + command: | + BINARY_PATH=$(dirname $(cat binary_path.txt)) + TARGET_PATH=$(dirname $(cat target_path.txt)) + ls -la ${BINARY_PATH} + cp -r ${BINARY_PATH}/*.tar.gz . + printf "gsutil cp -r *.tar.gz gs://public-nodejs-binary/@6river/${TARGET_PATH}/" + gsutil cp -r *.tar.gz gs://public-nodejs-binary/@6river/${TARGET_PATH}/ + gsutil acl ch -r -u AllUsers:R gs://public-nodejs-binary/@6river/${TARGET_PATH} + publish: + docker: + - image: circleci/node:10.15.3 + steps: + - checkout + - run: + name: Setup NPM + command: npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}" + - run: + name: Publish + command: npm publish --access public + +workflows: + build_and_release: + jobs: + - build-arm64 + - build-amd64 + - upload: + context: 6rs-circle + requires: + - build-amd64 + - build-arm64 + - publish: + context: 6rs-public-npm + requires: + - upload + filters: + branches: + only: master + + + diff --git a/amd64.dockerfile b/amd64.dockerfile new file mode 100644 index 000000000..86368a1be --- /dev/null +++ b/amd64.dockerfile @@ -0,0 +1,17 @@ +FROM balenalib/amd64-ubuntu-node:10-cosmic + +RUN apt-get update && apt-get install -y libsqlite3-dev build-essential python-dev + +COPY . . + +RUN npm install --build-from-source + +RUN ./node_modules/.bin/node-pre-gyp build package +RUN find build/stage -iname "*.tar.gz" | sed 's/^.*@6river/@6river/' > binary_path.txt +RUN find build/stage -iname "*.tar.gz" | sed 's/^.*sqlite3/sqlite3/' > target_path.txt + +FROM google/cloud-sdk:alpine +WORKDIR / +COPY --from=0 /binary_path.txt . +COPY --from=0 /target_path.txt . +COPY --from=0 /build/stage/ . diff --git a/arm64.dockerfile b/arm64.dockerfile new file mode 100644 index 000000000..8558f0793 --- /dev/null +++ b/arm64.dockerfile @@ -0,0 +1,21 @@ +FROM balenalib/aarch64-ubuntu-node:10-cosmic + +RUN [ "cross-build-start" ] + +RUN apt-get update && apt-get install -y libsqlite3-dev build-essential python-dev + +COPY . . + +RUN npm install --build-from-source + +RUN ./node_modules/.bin/node-pre-gyp build package +RUN find build/stage -iname "*.tar.gz" | sed 's/^.*@6river/@6river/' > binary_path.txt +RUN find build/stage -iname "*.tar.gz" | sed 's/^.*sqlite3/sqlite3/' > target_path.txt +RUN [ "cross-build-end" ] + + +FROM google/cloud-sdk:alpine +WORKDIR / +COPY --from=0 /binary_path.txt . +COPY --from=0 /target_path.txt . +COPY --from=0 /build/stage/ . diff --git a/package.json b/package.json index 530f3c709..5dce20c1a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "sqlite3", + "name": "@6river/sqlite3", "description": "Asynchronous, non-blocking SQLite3 bindings", "version": "4.1.0", "homepage": "https://github.com/mapbox/node-sqlite3", @@ -10,7 +10,7 @@ "binary": { "module_name": "node_sqlite3", "module_path": "./lib/binding/{node_abi}-{platform}-{arch}", - "host": "https://mapbox-node-binary.s3.amazonaws.com", + "host": "https://storage.googleapis.com/public-nodejs-binary", "remote_path": "./{name}/v{version}/{toolset}/", "package_name": "{node_abi}-{platform}-{arch}.tar.gz" },