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
36 changes: 36 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Optional live API checks. Add repository secret HACKMD_E2E_ACCESS_TOKEN.
# Optionally add HACKMD_E2E_API_ENDPOINT (e.g. https://api-stage.hackmd.io/v1); otherwise production is used.

name: E2E (live HackMD API)

on:
workflow_dispatch:

jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: nodejs/package-lock.json

- name: Install dependencies
working-directory: nodejs
run: npm ci

- name: Run e2e tests
working-directory: nodejs
env:
HACKMD_ACCESS_TOKEN: ${{ secrets.HACKMD_E2E_ACCESS_TOKEN }}
HACKMD_API_ENDPOINT: ${{ secrets.HACKMD_E2E_API_ENDPOINT }}
run: |
if [ -z "${HACKMD_ACCESS_TOKEN:-}" ]; then
echo "::error::Add repository secret HACKMD_E2E_ACCESS_TOKEN (a valid API token for the target environment)."
exit 1
fi
npm run test:e2e
99 changes: 93 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ on:
push:
tags:
- 'v*'
branches:
- develop

permissions:
id-token: write # OIDC for npm trusted publishing
contents: write # draft / pre-releases via gh

jobs:
publish:
publish-release:
name: Release (tag)
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: '20'
node-version: '24'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: nodejs/package-lock.json
Expand All @@ -30,5 +38,84 @@ jobs:
- name: Publish to NPM
working-directory: nodejs
run: npm 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:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
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: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: nodejs/package-lock.json

- name: Install dependencies
working-directory: nodejs
run: npm ci

- 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
npm version $PRE_RELEASE_VERSION --no-git-tag-version

- name: Build
working-directory: nodejs
run: npm run build

- name: Publish pre-release to NPM
working-directory: nodejs
run: npm 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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ To run the Node.js example:

The example includes detailed comments and demonstrates best practices for using the HackMD API client.

### Book Mode Conference Note Example

The `examples/book-mode-conference/` directory contains a TypeScript example for creating a "book mode" conference note system:

- **Book Mode Notes**: Creates a master note that links to all session notes
- **Bulk Note Creation**: Automatically creates individual notes for each conference session
- **TypeScript Implementation**: Full type safety with tsx support for direct execution
- **Configurable Templates**: Customizable note templates and conference settings
- **Hierarchical Organization**: Sessions organized by day and time in the main book
- **Error Handling**: Graceful handling of API failures during bulk operations

To run the book mode conference example:

1. Navigate to the example directory: `cd examples/book-mode-conference`
2. Follow the setup instructions in [examples/book-mode-conference/README.md](./examples/book-mode-conference/README.md)
3. Customize the configuration constants and session data
4. Set your HackMD access token
5. Run `npm start`

This example demonstrates advanced usage patterns including bulk operations, team note management, and creating interconnected note structures for conferences or events.

## LICENSE

MIT
49 changes: 49 additions & 0 deletions examples/book-mode-conference/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# HackMD Conference Note Generation Environment Variables

# Required: HackMD API Access Token
# Get this from your HackMD instance settings > API tokens
# For hackmd.io: https://hackmd.io/@hackmd-api/developer-portal
HACKMD_ACCESS_TOKEN=your_access_token_here

# Required: HackMD API Endpoint URL
# For hackmd.io: https://api.hackmd.io/v1
# For self-hosted: https://your-hackmd-instance.com/api/v1
HACKMD_API_ENDPOINT=https://api.hackmd.io/v1

# Optional: HackMD Web Domain (for generating correct note URLs)
# This is useful when your API endpoint differs from the web domain
# For hackmd.io: https://hackmd.io
# For self-hosted: https://your-hackmd-instance.com
# If not set, defaults to the API endpoint
HACKMD_WEB_DOMAIN=https://hackmd.io

# Optional: Test Mode
# Set to 'true' to create limited notes for testing
# Set to 'false' or omit for full note generation
TEST_MODE=false

# Optional: Resume Mode
# Set to 'true' to resume from previous interrupted execution
# Set to 'false' or omit for fresh generation
RESUME_MODE=false

# Optional: Fixed delay (milliseconds) between API requests
# Use to avoid rate limits in production environments
# Can also be set via --delay-ms CLI flag
# Recommended: 200-500ms for production
REQUEST_DELAY_MS=0

# Example configurations:
#
# For hackmd.io:
# HACKMD_API_ENDPOINT=https://api.hackmd.io/v1
# HACKMD_WEB_DOMAIN=https://hackmd.io
#
# For self-hosted HackMD:
# HACKMD_API_ENDPOINT=https://your-hackmd.example.com/api/v1
# HACKMD_WEB_DOMAIN=https://your-hackmd.example.com
#
# Production environment example:
# TEST_MODE=false
# REQUEST_DELAY_MS=300
# RESUME_MODE=false
Loading
Loading