Anki MCP Server
by nailuoGG
- anki-mcp-server
- .github
- workflows
name: Beta Release
on:
push:
branches:
- release-beta/*
jobs:
beta-test:
name: Beta Release Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
# - name: Run tests
# run: npm test
beta-publish:
name: Publish Beta to NPM
needs: beta-test
runs-on: ubuntu-latest
permissions:
contents: write # Changed from read to write to allow pushing tags
id-token: write # Required for npm provenance
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Get current version
id: current_version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Generate beta version
id: beta_version
run: |
# Get the current version from package.json
CURRENT_VERSION=${{ steps.current_version.outputs.version }}
# Get the latest beta version for this version if it exists
LATEST_BETA=$(npm view anki-mcp-server versions --json | jq -r ".[] | select(. | startswith(\"$CURRENT_VERSION-beta.\"))" | sort -V | tail -n 1 || echo "")
if [ -z "$LATEST_BETA" ]; then
# No existing beta for this version, create first beta
BETA_VERSION="$CURRENT_VERSION-beta.1"
else
# Extract the beta number and increment it
BETA_NUMBER=$(echo $LATEST_BETA | sed -E 's/.*beta\.([0-9]+)$/\1/')
NEXT_BETA=$((BETA_NUMBER + 1))
BETA_VERSION="$CURRENT_VERSION-beta.$NEXT_BETA"
fi
echo "version=$BETA_VERSION" >> $GITHUB_OUTPUT
echo "Beta version will be: $BETA_VERSION"
- name: Update package.json version
run: npm version ${{ steps.beta_version.outputs.version }} --no-git-tag-version
- name: Publish to NPM with beta tag
run: npm publish --provenance --access public --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Git Tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git remote set-url origin https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git tag v${{ steps.beta_version.outputs.version }}
git push origin v${{ steps.beta_version.outputs.version }}