diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..528131a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,127 @@ +name: release + +env: + NODE_VERSION: 18.x + +on: + push: + tags: + - '*' + +jobs: + node_18_linux: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: mapbox/configure-aws-credentials-internal@v4 + with: + target-account-id: ${{ vars.AWS_ACCOUNT_ID_DEFAULT }} + - uses: mapbox/setup-github-tokens@v2 + with: + scope-type: 'reader' + - uses: actions/checkout@v4 + with: + submodules: true + token: '${{ env.GITHUB_READER_TOKEN }}' + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: compare tags + run: | + PKG_VERSION=`cat package.json | jq -r '.version'` + echo "Checking that package version [v$PKG_VERSION] matches release tag [${{ github.ref_name }}]" + [ "${{ github.ref_type }}" = "tag" ] && [ "${{ github.ref_name }}" = "v$PKG_VERSION" ] + - uses: mapbox/setup-npm-token@v1.4.0 + with: + scope: 'readwrite' + - name: build + run: make release + - name: test + run: npm test + - name: publish binary + run: ./node_modules/.bin/node-pre-gyp package publish + + node_18_macos: + runs-on: macos-12 + permissions: + id-token: write + contents: read + steps: + - uses: mapbox/configure-aws-credentials-internal@v4 + with: + target-account-id: ${{ vars.AWS_ACCOUNT_ID_DEFAULT }} + - uses: mapbox/setup-github-tokens@v2 + with: + scope-type: 'reader' + - uses: actions/checkout@v4 + with: + submodules: true + token: '${{ env.GITHUB_READER_TOKEN }}' + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: compare tags + run: | + PKG_VERSION=`cat package.json | jq -r '.version'` + echo "Checking that package version [v$PKG_VERSION] matches release tag [${{ github.ref_name }}]" + [ "${{ github.ref_type }}" = "tag" ] && [ "${{ github.ref_name }}" = "v$PKG_VERSION" ] + - uses: mapbox/setup-npm-token@v1.4.0 + with: + scope: 'readwrite' + - name: build + run: make release + - name: test + run: npm test + - name: publish binary + run: ./node_modules/.bin/node-pre-gyp package publish + + # publishes the NPM package after binaries for linux and macos have been + # built and sent to s3 + node_npm_publish: + runs-on: ubuntu-latest + needs: [node_18_linux, node_18_macos] + permissions: + id-token: write + contents: read + steps: + - uses: mapbox/configure-aws-credentials-internal@v4 + with: + target-account-id: ${{ vars.AWS_ACCOUNT_ID_DEFAULT }} + - uses: mapbox/setup-github-tokens@v2 + with: + scope-type: 'reader' + - uses: actions/checkout@v4 + with: + submodules: true + token: '${{ env.GITHUB_READER_TOKEN }}' + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + - uses: mapbox/setup-npm-token@v1.4.0 + with: + scope: 'readwrite' + - name: publish package + run: | + PKG_VERSION=`cat package.json | jq -r '.version'` + # convert "null" to an empty string so we can check + # if the variable is defined or not + PKG_PRERELEASE=`cat package.json | jq -r '.version / "-" | .[1] | select (.!=null)'` + echo "VERSION: $PKG_VERSION, PRERELEASE: $PKG_PRERELEASE" + if [[ -z "$PKG_PRERELEASE" ]]; then + echo "publishing latest release for $PKG_VERSION" + npm publish + else + echo "publishing dev release for $PKG_VERSION" + npm publish --tag dev + fi \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5182b7e..acff8dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mapbox/vtcomposite", - "version": "2.1.0", + "version": "2.2.0-gha-test", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@mapbox/vtcomposite", - "version": "2.1.0", + "version": "2.2.0-gha-test", "hasInstallScript": true, "license": "ISC", "dependencies": { @@ -3143,7 +3143,8 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "dev": true, + "requires": {} }, "agent-base": { "version": "6.0.2", @@ -3631,7 +3632,8 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.0.0.tgz", "integrity": "sha512-7GPezalm5Bfi/E22PnQxDWH2iW9GTvAlUNTztemeHb6c1BniSyoeTrM87JkC0wYdi6aQrZX9p2qEiAno8aTcbw==", - "dev": true + "dev": true, + "requires": {} }, "eslint-scope": { "version": "7.1.1", @@ -4642,6 +4644,14 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=", + "requires": { + "safe-buffer": "~5.1.0" + } + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -4685,14 +4695,6 @@ "es-abstract": "^1.19.5" } }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=", - "requires": { - "safe-buffer": "~5.1.0" - } - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", diff --git a/package.json b/package.json index 3ffcae2..75a6157 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapbox/vtcomposite", - "version": "2.1.0", + "version": "2.2.0-gha-test", "description": "Compositing operations on Vector Tiles (c++ bindings using N-API)", "url": "http://github.com/mapbox/vtcomposite", "main": "./lib/index.js",