Skip to content
Open
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
65 changes: 38 additions & 27 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,41 +47,52 @@ jobs:
runs-on: ubuntu-24.04
needs: test
if: ${{ github.event_name == 'release' }}
# npm trusted publishing: npm exchanges the job's OIDC token for a publish
# token, so no NPM_TOKEN secret is needed
permissions:
contents: read
id-token: write
# Every step here can request an npm publish token, so only GitHub's own
# actions run, pinned to commits, and the checks are plain shell
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

- uses: actions/setup-node@v4
# Trusted publishing needs npm 11.5.1 or later. No registry-url: with it,
# setup-node writes a token entry to .npmrc and npm tries token auth
# instead of the OIDC exchange.
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
node-version: '24.14.1'

- name: Check package version matches tag
uses: geritol/match-tag-to-package-version@0.1.0
env:
TAG_PREFIX: refs/tags/v

- name: Enable NPM cache
uses: actions/cache@v4
with:
path: '~/.npm'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install NPM dependencies
run: npm ci
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
VERSION=$(node -p "require('./package.json').version")
if [ "$RELEASE_TAG" != "v$VERSION" ]; then
echo "::error::Release tag $RELEASE_TAG does not match package version v$VERSION"
exit 1
fi

# X.Y-dev for dev releases, latest otherwise
- name: Set release tag
uses: actions/github-script@v7
id: tag
with:
result-encoding: string
script: |
const tag = context.payload.release.tag_name;
const [, major, minor] = tag.match(/^v([0-9]+)\.([0-9]+)/);
return (tag.includes('dev') ? `${major}.${minor}-dev` : 'latest');
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
if [[ "$RELEASE_TAG" == *dev* ]]; then
[[ "$RELEASE_TAG" =~ ^v([0-9]+)\.([0-9]+) ]]
echo "result=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}-dev" >> "$GITHUB_OUTPUT"
else
echo "result=latest" >> "$GITHUB_OUTPUT"
fi

# Packs the checkout without installing anything: with --ignore-scripts no
# package script runs while the OIDC token is available. Trusted publishing
# adds a provenance attestation, which requires package.json's
# repository.url to name this repository. --loglevel verbose is the only
# level at which npm logs why an OIDC token exchange failed.
- name: Publish NPM package
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ steps.tag.outputs.result }}
env:
NPM_TAG: ${{ steps.tag.outputs.result }}
run: npm publish --ignore-scripts --access public --tag "$NPM_TAG" --loglevel verbose
4 changes: 2 additions & 2 deletions package-lock.json

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

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"name": "@dashevo/dashcore-node",
"description": "Full node with extended capabilities using Dashcore and Dash Core (dashd)",
"author": "BitPay <dev@bitpay.com>",
"version": "7.0.6",
"version": "7.0.7",
"main": "./index.js",
"repository": "git://github.com/dashevo/dashcore-node.git",
"homepage": "https://github.com/dashevo/dashcore-node",
"repository": {
"type": "git",
"url": "git+https://github.com/dashpay/dashcore-node.git"
},
"homepage": "https://github.com/dashpay/dashcore-node",
"bugs": {
"url": "https://github.com/dashevo/dashcore-node/issues"
"url": "https://github.com/dashpay/dashcore-node/issues"
},
"contributors": [
{
Expand Down
Loading