Skip to content

Fix: Preserve Authorization headers in fetch instrumentation (#208) #84

Fix: Preserve Authorization headers in fetch instrumentation (#208)

Fix: Preserve Authorization headers in fetch instrumentation (#208) #84

Workflow file for this run

name: NPM Release
on:
workflow_dispatch: # Allow manual trigger
push:
branches:
- main
paths:
- 'package.json'
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 15
name: Publish to NPM
permissions:
contents: write # Required for creating tags
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check version change
if: github.event_name == 'push' # Only run version check on push events
id: check_version
run: |
PREV_VERSION=$(git show HEAD^:package.json | jq -r .version)
CURRENT_VERSION=$(jq -r .version package.json)
if [ "$PREV_VERSION" = "$CURRENT_VERSION" ]; then
echo "No version change detected, skipping release"
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
else
echo "Version changed from $PREV_VERSION to $CURRENT_VERSION"
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
fi
- name: Setup NPM
if: github.event_name != 'push' || steps.check_version.outputs.version_changed == 'true'
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
if: github.event_name != 'push' || steps.check_version.outputs.version_changed == 'true'
run: npm install
- name: Run lint
if: github.event_name != 'push' || steps.check_version.outputs.version_changed == 'true'
run: npm run lint
- name: Release to NPM
if: github.event_name != 'push' || steps.check_version.outputs.version_changed == 'true'
run: npm run release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push tags to Github
if: github.event_name != 'push' || steps.check_version.outputs.version_changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a v${{ steps.check_version.outputs.version }} -m "Release ${{ steps.check_version.outputs.version }}"
git push origin v${{ steps.check_version.outputs.version }}