name: Release
on:
push:
branches: [main]
permissions:
contents: write
id-token: write
issues: write
pull-requests: write
concurrency:
group: release-${{ github.repository }}
cancel-in-progress: false
jobs:
release:
name: Release and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build project
run: npm run build
- name: Create release info file
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
cat > release-info.json << EOF
{
"packageName": "$PACKAGE_NAME",
"npmRegistry": "https://www.npmjs.com/package/$PACKAGE_NAME",
"repository": "${{ github.repository }}",
"repositoryUrl": "https://github.com/${{ github.repository }}",
"commit": "${{ github.sha }}",
"buildDate": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"nodeVersion": "$(node --version)",
"npmVersion": "$(npm --version)",
"workflow": "${{ github.run_id }}",
"workflowUrl": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"note": "This file will be updated with version-specific NPM links after semantic-release runs"
}
EOF
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.SR_APP_ID }}
private-key: ${{ secrets.SR_PRIVATE_KEY }}
- name: Configure Git
run: |
git config --global user.name "semantic-release-idty[bot]"
git config --global user.email "semantic-release-idty[bot]@users.noreply.github.com"
- name: Run semantic release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release