|
1 | 1 | name: Publish to npm and Docker Hub |
2 | 2 |
|
3 | 3 | on: |
4 | | - # Triggered when release-please creates a tag |
5 | 4 | push: |
6 | 5 | tags: |
7 | 6 | - "v*" |
8 | | - # Triggered when a GitHub release is published (by release-please) |
9 | | - release: |
10 | | - types: [published] |
11 | | - # Manual trigger for testing |
12 | 7 | workflow_dispatch: |
13 | 8 | inputs: |
14 | 9 | version: |
15 | | - description: "Version to release (e.g., 1.0.0)" |
| 10 | + description: "Version (e.g., 1.0.0)" |
16 | 11 | required: true |
17 | 12 | type: string |
18 | | - tag: |
19 | | - description: "npm tag (latest, beta, alpha)" |
20 | | - required: false |
21 | | - default: "latest" |
22 | | - type: choice |
23 | | - options: |
24 | | - - latest |
25 | | - - beta |
26 | | - - alpha |
27 | 13 |
|
28 | 14 | env: |
29 | | - REGISTRY: docker.io |
30 | | - IMAGE_NAME: elpaypes/iexec-mcp |
| 15 | + IMAGE_NAME: elpaypes/mcp-server |
31 | 16 |
|
32 | 17 | jobs: |
33 | | - validate: |
| 18 | + publish: |
34 | 19 | runs-on: ubuntu-latest |
35 | | - outputs: |
36 | | - version: ${{ steps.get-version.outputs.version }} |
37 | | - is-prerelease: ${{ steps.check-prerelease.outputs.is-prerelease }} |
38 | 20 | steps: |
39 | | - - name: Checkout code |
40 | | - uses: actions/checkout@v4 |
41 | | - |
42 | | - - name: Get version from tag or input |
43 | | - id: get-version |
44 | | - run: | |
45 | | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
46 | | - VERSION="${{ github.event.inputs.version }}" |
47 | | - else |
48 | | - # Remove 'v' prefix from tag (v1.0.0 -> 1.0.0) |
49 | | - VERSION=${GITHUB_REF#refs/tags/v} |
50 | | - fi |
51 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
52 | | - echo "Version: $VERSION" |
53 | | -
|
54 | | - - name: Check if prerelease |
55 | | - id: check-prerelease |
56 | | - run: | |
57 | | - VERSION="${{ steps.get-version.outputs.version }}" |
58 | | - if [[ $VERSION =~ (alpha|beta|rc) ]]; then |
59 | | - echo "is-prerelease=true" >> $GITHUB_OUTPUT |
60 | | - else |
61 | | - echo "is-prerelease=false" >> $GITHUB_OUTPUT |
62 | | - fi |
63 | | -
|
64 | | - - name: Setup Node.js |
65 | | - uses: actions/setup-node@v4 |
66 | | - with: |
67 | | - node-version: "18" |
68 | | - cache: "npm" |
69 | | - |
70 | | - - name: Install dependencies |
71 | | - run: npm ci |
72 | | - |
73 | | - # - name: Run tests |
74 | | - # run: npm test |
75 | | - |
76 | | - - name: Build project |
77 | | - run: npm run build |
78 | | - |
79 | | - npm-release: |
80 | | - needs: validate |
81 | | - runs-on: ubuntu-latest |
82 | | - steps: |
83 | | - - name: Checkout code |
| 21 | + - name: Checkout |
84 | 22 | uses: actions/checkout@v4 |
85 | 23 |
|
86 | 24 | - name: Setup Node.js |
87 | 25 | uses: actions/setup-node@v4 |
88 | 26 | with: |
89 | 27 | node-version: "18" |
90 | 28 | registry-url: "https://registry.npmjs.org" |
91 | | - cache: "npm" |
92 | | - |
93 | | - - name: Install dependencies |
94 | | - run: npm ci |
95 | | - |
96 | | - - name: Build project |
97 | | - run: npm run build |
98 | 29 |
|
99 | | - - name: Update package version |
100 | | - run: npm version ${{ needs.validate.outputs.version }} --no-git-tag-version |
101 | | - |
102 | | - - name: Determine npm tag |
103 | | - id: npm-tag |
| 30 | + - name: Get version |
| 31 | + id: version |
104 | 32 | run: | |
105 | 33 | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
106 | | - TAG="${{ github.event.inputs.tag }}" |
107 | | - elif [[ "${{ needs.validate.outputs.version }}" =~ (alpha|beta|rc) ]]; then |
108 | | - if [[ "${{ needs.validate.outputs.version }}" =~ alpha ]]; then |
109 | | - TAG="alpha" |
110 | | - elif [[ "${{ needs.validate.outputs.version }}" =~ beta ]]; then |
111 | | - TAG="beta" |
112 | | - else |
113 | | - TAG="next" |
114 | | - fi |
| 34 | + VERSION="${{ github.event.inputs.version }}" |
115 | 35 | else |
116 | | - TAG="latest" |
| 36 | + VERSION=${GITHUB_REF#refs/tags/v} |
117 | 37 | fi |
118 | | - echo "tag=$TAG" >> $GITHUB_OUTPUT |
119 | | - echo "Publishing to npm with tag: $TAG" |
| 38 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 39 | + echo "Publishing version: $VERSION" |
| 40 | +
|
| 41 | + - name: Install and build |
| 42 | + run: | |
| 43 | + npm ci |
| 44 | + npm run build |
120 | 45 |
|
121 | | - - name: Publish to npm @paypes |
122 | | - run: npm publish --tag ${{ steps.npm-tag.outputs.tag }} |
| 46 | + - name: Publish to npm |
| 47 | + run: | |
| 48 | + npm publish --access public |
123 | 49 | env: |
124 | 50 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
125 | 51 |
|
126 | | - docker-release: |
127 | | - needs: validate |
128 | | - runs-on: ubuntu-latest |
129 | | - steps: |
130 | | - - name: Checkout code |
131 | | - uses: actions/checkout@v4 |
132 | | - |
133 | | - - name: Set up Docker Buildx |
134 | | - uses: docker/setup-buildx-action@v3 |
135 | | - |
136 | | - - name: Log in to Docker Hub |
| 52 | + - name: Docker login |
137 | 53 | uses: docker/login-action@v3 |
138 | 54 | with: |
139 | 55 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
140 | 56 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
141 | 57 |
|
142 | | - - name: Extract metadata |
143 | | - id: meta |
144 | | - uses: docker/metadata-action@v5 |
145 | | - with: |
146 | | - images: ${{ env.IMAGE_NAME }} |
147 | | - tags: | |
148 | | - type=raw,value=${{ needs.validate.outputs.version }} |
149 | | - type=raw,value=latest,enable=${{ needs.validate.outputs.is-prerelease == 'false' }} |
150 | | -
|
151 | | - - name: Build and push Docker image to elpaypes |
| 58 | + - name: Build and push Docker |
152 | 59 | uses: docker/build-push-action@v5 |
153 | 60 | with: |
154 | 61 | context: . |
155 | | - platforms: linux/amd64,linux/arm64 |
156 | 62 | push: true |
157 | | - tags: ${{ steps.meta.outputs.tags }} |
158 | | - labels: ${{ steps.meta.outputs.labels }} |
159 | | - cache-from: type=gha |
160 | | - cache-to: type=gha,mode=max |
161 | | - |
162 | | - notify: |
163 | | - needs: [validate, npm-release, docker-release] |
164 | | - runs-on: ubuntu-latest |
165 | | - if: always() |
166 | | - steps: |
167 | | - - name: Notify on success |
168 | | - if: needs.npm-release.result == 'success' && needs.docker-release.result == 'success' |
169 | | - run: | |
170 | | - echo "✅ Successfully published v${{ needs.validate.outputs.version }}" |
171 | | - echo "📦 npm: https://www.npmjs.com/package/@paypes/iexec-mcp" |
172 | | - echo "🐳 Docker: https://hub.docker.com/r/elpaypes/iexec-mcp" |
| 63 | + tags: | |
| 64 | + ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} |
| 65 | + ${{ env.IMAGE_NAME }}:latest |
173 | 66 |
|
174 | | - - name: Notify on failure |
175 | | - if: needs.npm-release.result == 'failure' || needs.docker-release.result == 'failure' |
| 67 | + - name: Success |
176 | 68 | run: | |
177 | | - echo "❌ Publication failed for v${{ needs.validate.outputs.version }}" |
178 | | - exit 1 |
| 69 | + echo "✅ Published v${{ steps.version.outputs.version }}" |
| 70 | + echo "📦 npm: https://www.npmjs.com/package/@paypes/mcp-server" |
| 71 | + echo "🐳 Docker: https://hub.docker.com/r/elpaypes/mcp-server" |
0 commit comments