New dev package #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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 |