Files
caballo-client/.github/workflows/release.yaml
Raul Lugo c9778f7a9c
All checks were successful
Publish to NPM / Build and Publish to NPM (push) Successful in 11s
fix: setup npmrc before publishing
2024-12-26 18:21:44 +01:00

58 lines
1.6 KiB
YAML

name: Publish to NPM
on:
push:
tags:
- "v*.*.*" # Matches version tags like v1.0.0, v2.3.4, etc.
env:
DIST_FOLDER: dist
jobs:
build-and-publish:
name: Build and Publish to NPM
runs-on: ubuntu-latest
steps:
# 1. Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v4
# 2. Extract Tag Version
- name: Extract Tag Version
id: tag_version
run: |
echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "Extracted Tag Version: ${GITHUB_REF#refs/tags/v}"
# 3. Replace Version Placeholder in `dnt.config.mts`
- name: Replace Version Placeholder
uses: bluwy/substitute-string-action@v3
with:
_input-file: 'dnt.config.mts'
_output-file: 'dnt.config.mts' # Overwrite the same file
_format-key: '<key>' # Use '<>' as placeholder delimiters
RELEASE_VERSION_PLACEHOLDER: ${{ env.TAG_VERSION }}
- name: Validate Version Substitution
run: grep 'version' dnt.config.mts
# 4. Install Deno v2
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x # Use the latest stable Deno v2
# 5. Run build:npm
- name: Build NPM Package
run: deno task build:npm
- name: Setup .npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
# 6. Publish to NPM
- name: Publish to NPM
run: |
cd ${{ env.DIST_FOLDER }}
npm publish --access public