83 lines
2.9 KiB
YAML
83 lines
2.9 KiB
YAML
name: Release and Deploy Build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: use NodeJS v24.14.0
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24.14.0'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Ensure trusted publishing capable npm
|
|
run: npm install -g npm@^11.5.1
|
|
|
|
- name: Install Dependencies
|
|
run: npm ci
|
|
|
|
- name: Run Checks
|
|
run: npm run check
|
|
|
|
- name: Set Release Version
|
|
id: version
|
|
run: npm run release:version
|
|
|
|
- name: Export Release Version
|
|
id: release_version
|
|
run: |
|
|
package_version="$(node -p "require('./package.json').version")"
|
|
echo "tag=${package_version}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Run Build
|
|
run: npm run build
|
|
|
|
- name: Publish Library
|
|
run: npm publish --access public
|
|
|
|
- name: Create GitHub release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RELEASE_TAG: v${{ steps.release_version.outputs.tag }}
|
|
run: |
|
|
previous_tag="$(gh api repos/${{ github.repository }}/releases --paginate --jq '.[] | select(.draft == false) | .tag_name' | grep -Fxv "$RELEASE_TAG" | head -n 1 || true)"
|
|
|
|
if [ -n "$previous_tag" ]; then
|
|
commit_messages="$(git log --reverse --format='- %s' "${previous_tag}..${GITHUB_SHA}")"
|
|
full_changelog="https://github.com/${{ github.repository }}/compare/${previous_tag}...${RELEASE_TAG}"
|
|
else
|
|
commit_messages="$(git log --reverse --format='- %s' "${GITHUB_SHA}")"
|
|
full_changelog=""
|
|
fi
|
|
|
|
if [ -z "$commit_messages" ]; then
|
|
commit_messages='- No commits since the previous release'
|
|
fi
|
|
|
|
{
|
|
echo '## Changes'
|
|
echo
|
|
printf '%s\n' "$commit_messages"
|
|
echo
|
|
if [ -n "$full_changelog" ]; then
|
|
echo "**Full Changelog**: ${full_changelog}"
|
|
fi
|
|
} > release-notes.md
|
|
|
|
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
|
|
gh release edit "$RELEASE_TAG" --title "$RELEASE_TAG" --notes-file release-notes.md
|
|
else
|
|
gh release create "$RELEASE_TAG" --target "${GITHUB_SHA}" --title "$RELEASE_TAG" --notes-file release-notes.md
|
|
fi
|