|
| 1 | +# ⚠️ THIS WORKFLOW IS THE TRUSTED PUBLISHER CONFIGURED ON NPMJS.COM, DO NOT RENAME OR DELETE THIS FILE ⚠️ |
1 | 2 | name: Publish to npm |
2 | 3 |
|
3 | 4 | on: |
| 5 | + # For staging releases |
| 6 | + workflow_dispatch: |
| 7 | + # For latest releases |
4 | 8 | release: |
5 | 9 | types: [published] |
6 | | - workflow_dispatch: |
7 | | - inputs: |
8 | | - version: |
9 | | - description: "Version (e.g., 1.0.0)" |
10 | | - required: true |
11 | | - type: string |
| 10 | + |
| 11 | +permissions: |
| 12 | + id-token: write # Required for OIDC |
| 13 | + packages: write |
| 14 | + contents: read |
12 | 15 |
|
13 | 16 | jobs: |
14 | | - publish: |
| 17 | + set-staging-version: |
| 18 | + # Only run for manual dispatch on main branch |
| 19 | + if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }} |
15 | 20 | runs-on: ubuntu-latest |
16 | 21 | steps: |
17 | | - - name: Checkout |
| 22 | + - name: Checkout code |
18 | 23 | uses: actions/checkout@v4 |
19 | | - |
20 | | - - name: Setup Node.js |
| 24 | + - name: Set up Node.js |
21 | 25 | uses: actions/setup-node@v4 |
22 | | - with: |
23 | | - node-version: "18" |
24 | | - registry-url: "https://registry.npmjs.org" |
25 | | - |
26 | | - - name: Get version |
27 | | - id: version |
28 | | - run: | |
29 | | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
30 | | - VERSION="${{ github.event.inputs.version }}" |
31 | | - else |
32 | | - VERSION=${GITHUB_REF#refs/tags/v} |
33 | | - fi |
34 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
35 | | - echo "Publishing version: $VERSION" |
36 | | -
|
37 | | - - name: Install and build |
| 26 | + - name: Set publish version |
| 27 | + id: set-staging-version |
38 | 28 | run: | |
39 | | - npm ci |
40 | | - npm run build |
| 29 | + CURRENT_VERSION=$(npm pkg get version | tr -d '"') |
| 30 | + NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}" |
| 31 | + echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT |
| 32 | + outputs: |
| 33 | + VERSION: ${{ steps.set-staging-version.outputs.VERSION }} |
41 | 34 |
|
42 | | - - name: Publish to npm |
43 | | - run: npm publish --tag latest |
44 | | - env: |
45 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 35 | + publish-npm-staging: |
| 36 | + # Only run for manual dispatch on main branch |
| 37 | + if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }} |
| 38 | + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected] |
| 39 | + needs: set-staging-version |
| 40 | + with: |
| 41 | + scope: "@iexec/mcp-server" |
| 42 | + registry: "https://registry.npmjs.org" |
| 43 | + node-version: "20" |
| 44 | + tag: "nightly" |
| 45 | + version: ${{ needs.set-staging-version.outputs.VERSION }} |
46 | 46 |
|
47 | | - - name: Success |
48 | | - run: | |
49 | | - echo "✅ Published v${{ steps.version.outputs.version }}" |
50 | | - echo "📦 npm: https://www.npmjs.com/package/@iexec/mcp-server" |
| 47 | + publish-npm-latest: |
| 48 | + # # Only run for release published with tag "v*" |
| 49 | + if: ${{ github.event_name == 'release' && startsWith(github.ref_name,'v') }} |
| 50 | + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected] |
| 51 | + with: |
| 52 | + scope: "@iexec/mcp-server" |
| 53 | + registry: "https://registry.npmjs.org" |
| 54 | + node-version: "20" |
| 55 | + tag: "latest" |
0 commit comments