Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHA release workflows #137

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[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
26 changes: 14 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading