105 lines
3.6 KiB
YAML
105 lines
3.6 KiB
YAML
name: Build Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
# Give the default GITHUB_TOKEN write permission to commit and push the
|
|
# added or changed files to the repository.
|
|
contents: write
|
|
# Allow the job to send a JWT token request to the OIDC provider
|
|
id-token: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
with:
|
|
ref: ${{ github.head_ref }}
|
|
|
|
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
|
with:
|
|
node-version: '22.x'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- 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: Install dependencies
|
|
run: npm install
|
|
|
|
- name: Bump version
|
|
id: bump-version
|
|
run: |
|
|
TAG=$(npm version patch --no-git-tag-version)
|
|
VERSION=${TAG#v}
|
|
jq --arg v "$VERSION" '(.version,.packages[].version) = $v' server.json > tmp && mv tmp server.json
|
|
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build assets
|
|
run: npm run build
|
|
|
|
- name: Commit build assets
|
|
run: |
|
|
git add package.json package-lock.json
|
|
git commit -m "ci: update build assets (${{ steps.bump-version.outputs.tag }})"
|
|
git push
|
|
|
|
- name: Create release
|
|
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # v2.3.3
|
|
with:
|
|
tag_name: ${{ steps.bump-version.outputs.tag }}
|
|
generate_release_notes: true
|
|
make_latest: true
|
|
|
|
- name: Publish NPM package
|
|
run: npm publish --no-git-checks --access public
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
|
|
with:
|
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build \
|
|
-t ${GITHUB_REPOSITORY}:${{ steps.bump-version.outputs.tag }} \
|
|
-t ${GITHUB_REPOSITORY}:${GITHUB_SHA} \
|
|
-t ${GITHUB_REPOSITORY}:${GITHUB_SHA::7} \
|
|
-t ${GITHUB_REPOSITORY}:latest \
|
|
.
|
|
|
|
- name: Push to Docker Hub
|
|
run: docker push ${GITHUB_REPOSITORY} --all-tags
|
|
|
|
- name: Install MCP Publisher
|
|
run: |
|
|
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v1.0.0/mcp-publisher_1.0.0_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
|
|
|
|
- name: Wait for NPM package propagation
|
|
run: |
|
|
VERSION="${{ steps.bump-version.outputs.version }}"
|
|
echo "Waiting for NPM package version $VERSION to be available..."
|
|
for i in {1..30}; do
|
|
if curl -s "https://registry.npmjs.org/@brave/brave-search-mcp-server" | jq -e ".versions[\"$VERSION\"]" > /dev/null; then
|
|
echo "Package version $VERSION is available on NPM registry"
|
|
break
|
|
fi
|
|
echo "Attempt $i/30: Package version $VERSION not yet available, waiting 10 seconds..."
|
|
sleep 10
|
|
done
|
|
|
|
- name: Login to MCP Registry
|
|
run: ./mcp-publisher login github-oidc
|
|
|
|
- name: Publish to MCP Registry
|
|
run: ./mcp-publisher publish
|