Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions .github/workflows/ci-publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@ on:
- 'v*'
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci
Expand All @@ -30,27 +36,25 @@ jobs:

- name: Extract Package Version
id: extract_version
run: echo "package_version=$(node -p "require('./package.json').version")" >> $GITHUB_ENV

- name: Authenticate to npm registry
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
run: echo "package_version=$(node -p \"require('./package.json').version\")" >> $GITHUB_ENV

- name: Generate Release Notes
id: generate_release_notes
run: |
git fetch --tags

if [ "v${{ env.package_version }}" != "${GITHUB_REF_NAME}" ]; then
echo "package.json version and tag mismatch"
exit 1
fi

current_tag="v${{ env.package_version }}"
last_tag=$(git tag --sort=-creatordate | grep -A1 "$current_tag" | tail -n 1)
last_tag=$(git describe --tags --abbrev=0 "${current_tag}^" 2>/dev/null || true)

if [ -z "$last_tag" ]; then
echo "No previous tag found. Generating release notes for all history."
git log --pretty=format:"* %s" > release_notes.md
else
echo "Generating release notes from $last_tag to $current_tag."
git log --pretty=format:"* %s" "${last_tag}..HEAD" > release_notes.md
git log --pretty=format:"* %s" "${last_tag}..${current_tag}" > release_notes.md
fi

sed -i 's/ (#\([0-9]*\))/ (PR #\1)/' release_notes.md
Expand All @@ -61,7 +65,7 @@ jobs:

- name: Publish to npm
id: publish
run: npm publish --ignore-scripts
run: npm publish --provenance --ignore-scripts

- name: Create GitHub Release
if: ${{ steps.publish.outcome == 'success' }}
Expand All @@ -88,4 +92,4 @@ jobs:
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.RELEASES_PROD_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
3 changes: 1 addition & 2 deletions .secrets
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ SEED_PHRASE_18=_seed_phrase_18_
SEED_PHRASE_19=_seed_phrase_19_
SEED_PHRASE_20=_seed_phrase_20_
QA_SLACK_WEBHOOK_URL=_webhook_url_
RELEASES_PROD_SLACK_WEBHOOK_URL=_releases_prod_webhook_url_
NPM_TOKEN=_npm_token_
RELEASES_PROD_SLACK_WEBHOOK_URL=_releases_prod_webhook_url_