-
Notifications
You must be signed in to change notification settings - Fork 56
84 lines (72 loc) · 2.61 KB
/
Copy pathpublish-github-packages.yml
File metadata and controls
84 lines (72 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Publish @kiliczsh/mcp-mongo-server
on:
release:
types: [created]
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build
run: bun run build
publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
STATIC_VERSION: "2.0.2"
BUILD_ID: ${{ github.run_number }}
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
- uses: actions/setup-node@v5
with:
node-version: 22
registry-url: https://npm.pkg.github.com/
- name: Copy GitHub NPM configuration
run: cp .npmrc-github .npmrc
- name: Determine Version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
VERSION="${STATIC_VERSION}-main.${BUILD_ID}"
else
VERSION="${STATIC_VERSION}-build.${BUILD_ID}"
fi
echo "Using version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Git Tag
if: github.event_name != 'release'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -a "$VERSION" -m "Version $VERSION"
git push https://${{ secrets.NODE_AUTH_TOKEN }}@github.com/kiliczsh/mcp-mongo-server.git "$VERSION"
- name: Update package.json version and publishConfig
run: |
sed -i 's/"name": "mcp-mongo-server"/"name": "@kiliczsh\/mcp-mongo-server"/' package.json
jq --arg version "$VERSION" '.version = $version' package.json > package.tmp.json && mv package.tmp.json package.json
echo '{
"access": "public",
"registry": "https://npm.pkg.github.com"
}' > publishConfig.json
jq -s '.[0] * {publishConfig: .[1]}' package.json publishConfig.json > package.tmp.json && mv package.tmp.json package.json
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build
run: bun run build
- name: Publish package to GitHub Packages
run: npm publish --registry=https://npm.pkg.github.com
env:
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}