Files
express-prom-bundle/.github/workflows/release.yml

90 lines
2.6 KiB
YAML

name: Release
on:
push:
branches:
- main
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22, 24, latest]
steps:
- uses: actions/checkout@v6
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- run: npm install prom-client
- run: npm install
- run: npm run lint
- run: npm test
- run: npm run test-types
- name: Generate coverage
run: make coverage
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage/lcov.info
publish:
needs: test
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v6
- name: Use Node.js 22
uses: actions/setup-node@v6
with:
node-version: 22
- name: Debug GitHub OIDC context
run: |
echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY"
echo "GITHUB_REF=$GITHUB_REF"
echo "GITHUB_WORKFLOW_REF=$GITHUB_WORKFLOW_REF"
- name: Show Node and npm versions
run: |
node --version
npm --version
- name: Update npm for Trusted Publishing
run: npm install -g npm@latest
- name: Ensure no legacy npm auth token is set
run: npm config delete //registry.npmjs.org/:_authToken || true
- run: npm ci
- run: npm publish --provenance --access public --registry=https://registry.npmjs.org
release:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get version
id: get_version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Generate Changelog
run: |
# Simple changelog generation
echo "# Changelog" > CHANGELOG.md
git log --oneline --pretty=format:"- %s" $(git describe --tags --abbrev=0 2>/dev/null || echo "HEAD~1")..HEAD >> CHANGELOG.md
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Release v${{ steps.get_version.outputs.version }}
body_path: CHANGELOG.md
draft: false
prerelease: false