Skip to content

chore: upgrade runtime to node 24 (#56) #6

chore: upgrade runtime to node 24 (#56)

chore: upgrade runtime to node 24 (#56) #6

Workflow file for this run

name: Publish to NPM
on:
push:
tags:
- 'v*'
branches:
- develop
permissions:
id-token: write # OIDC for npm trusted publishing
contents: write # draft / pre-releases via gh
jobs:
publish-release:
name: Release (tag)
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 10.33.2
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
cache-dependency-path: nodejs/pnpm-lock.yaml
- name: Install dependencies
working-directory: nodejs
run: pnpm install --frozen-lockfile
- name: Build
working-directory: nodejs
run: pnpm build
- name: Publish to NPM
working-directory: nodejs
run: pnpm publish --access public
- name: Extract version from tag
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Create draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" \
--title "Release v${VERSION}" \
--draft
publish-prerelease:
name: Pre-release (develop)
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 10.33.2
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
cache-dependency-path: nodejs/pnpm-lock.yaml
- name: Install dependencies
working-directory: nodejs
run: pnpm install --frozen-lockfile
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Generate pre-release version
working-directory: nodejs
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
SHORT_SHA=$(git rev-parse --short HEAD)
TIMESTAMP=$(date +%Y%m%d%H%M%S)
PRE_RELEASE_VERSION="${CURRENT_VERSION}-beta.${TIMESTAMP}.${SHORT_SHA}"
echo "Pre-release version: $PRE_RELEASE_VERSION"
echo "PRE_RELEASE_VERSION=$PRE_RELEASE_VERSION" >> $GITHUB_ENV
pnpm version $PRE_RELEASE_VERSION --no-git-tag-version
- name: Build
working-directory: nodejs
run: pnpm build
- name: Publish pre-release to NPM
working-directory: nodejs
run: pnpm publish --tag beta --access public
- name: Create GitHub pre-release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${PRE_RELEASE_VERSION}" \
--title "Pre-release v${PRE_RELEASE_VERSION}" \
--notes "🚀 **Pre-release from develop branch**
This is an automated pre-release build from the develop branch.
**Changes:**
- Commit: ${{ github.sha }}
- Branch: ${{ github.ref_name }}
**Installation:**
\`\`\`bash
npm install @hackmd/api@beta
\`\`\`
**Note:** This is a pre-release version and may contain unstable features." \
--prerelease