Skip to content

1.2.5

1.2.5 #13

Workflow file for this run

name: Release and Publish
on:
push:
tags:
- "v*" # Triggers on version tags like v1.0.0, v1.2.3, etc.
jobs:
release:
name: Release and Publish with Bun
runs-on: ubuntu-latest
permissions:
contents: write # Needed to create releases
id-token: write # Needed for npm provenance
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for changelog generation
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run tests
run: bun test
- name: Type check
run: bun run tsc --noEmit
- name: Build package
run: bun run build
- name: Verify build artifacts
run: |
if [ ! -d "dist" ]; then
echo "Build failed: dist directory not found"
exit 1
fi
if [ ! -f "dist/index.js" ]; then
echo "Build failed: dist/index.js not found"
exit 1
fi
if [ ! -f "dist/index.d.ts" ]; then
echo "Build failed: dist/index.d.ts not found"
exit 1
fi
echo "Build artifacts verified successfully"
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Update package.json version
run: |
bun -e "
const pkg = require('./package.json');
pkg.version = '${{ steps.get_version.outputs.version }}';
require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Verify package can be packed
run: |
bun publish --dry-run
echo "Package dry-run successful"
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_CONFIG_TOKEN }}
- name: Publish to npm with Bun
run: bun publish --access public
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_CONFIG_TOKEN }}
- name: Generate changelog
id: changelog
run: |
# Simple changelog generation - you can enhance this
echo "## What's Changed" > CHANGELOG.md
echo "" >> CHANGELOG.md
# Get commits since last tag
LAST_TAG=$(git tag --sort=-version:refname | sed -n '2p')
if [ -z "$LAST_TAG" ]; then
# If no previous tag, get all commits
git log --pretty=format:"- %s (%h)" --no-merges >> CHANGELOG.md
else
# Get commits since last tag
git log "${LAST_TAG}..${{ steps.get_version.outputs.tag }}" --pretty=format:"- %s (%h)" --no-merges >> CHANGELOG.md
fi
echo "" >> CHANGELOG.md
echo "**Full Changelog**: https://github.com/max-programming/typed-id/compare/${LAST_TAG:-$(git rev-list --max-parents=0 HEAD)}...${{ steps.get_version.outputs.tag }}" >> CHANGELOG.md
# Set changelog content for release
{
echo 'changelog<<EOF'
cat CHANGELOG.md
echo EOF
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.tag }}
name: Release ${{ steps.get_version.outputs.tag }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
files: |
dist/index.js
dist/index.d.ts
dist/index.cjs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Notify on successful release
notify:
name: Notify Success
runs-on: ubuntu-latest
needs: release
if: success()
steps:
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Notify
run: |
echo "🎉 Successfully released typed-id v${{ steps.get_version.outputs.version }} with Bun!"
echo "📦 Published to npm: https://www.npmjs.com/package/typed-id"
echo "🏷️ GitHub Release: https://github.com/max-programming/typed-id/releases/tag/v${{ steps.get_version.outputs.version }}"