|
| 1 | +# ⚠️ THIS WORKFLOW IS THE TRUSTED PUBLISHER CONFIGURED ON NPMJS.COM, DO NOT RENAME OR DELETE THIS FILE ⚠️ |
1 | 2 | name: Deserializer - Publish NPM Package |
2 | 3 |
|
3 | 4 | on: |
| 5 | + # For staging releases |
4 | 6 | workflow_dispatch: |
5 | | - inputs: |
6 | | - tag: |
7 | | - description: 'NPM tag to publish (latest or nightly)' |
8 | | - required: true |
9 | | - type: choice |
10 | | - options: |
11 | | - - latest |
12 | | - - nightly |
13 | | - - beta |
14 | | - default: nightly |
| 7 | + # For latest releases |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +permissions: |
| 12 | + id-token: write # Required for OIDC |
| 13 | + packages: write |
| 14 | + contents: read |
15 | 15 |
|
16 | 16 | jobs: |
17 | | - set-publish-version: |
18 | | - # Run only on main branch |
19 | | - if: github.ref == 'refs/heads/main' |
| 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' }} |
20 | 20 | runs-on: ubuntu-latest |
21 | 21 | steps: |
22 | 22 | - name: Checkout code |
23 | 23 | uses: actions/checkout@v4 |
24 | 24 | - name: Set up Node.js |
25 | 25 | uses: actions/setup-node@v4 |
26 | 26 | - name: Set publish version |
27 | | - id: set-publish-version |
28 | | - if: github.event.inputs.tag == 'nightly' |
| 27 | + id: set-staging-version |
29 | 28 | working-directory: packages/dataprotector-deserializer |
30 | 29 | run: | |
31 | | - if [ "${{ github.event.inputs.tag }}" == "nightly" ]; then |
32 | | - CURRENT_VERSION=$(npm pkg get version | tr -d '"') |
33 | | - NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}" |
34 | | - echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT |
35 | | - else |
36 | | - echo "VERSION=$(npm pkg get version | tr -d '"')" >> $GITHUB_OUTPUT |
37 | | - fi |
| 30 | + CURRENT_VERSION=$(npm pkg get version | tr -d '"') |
| 31 | + NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}" |
| 32 | + echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT |
38 | 33 | outputs: |
39 | | - VERSION: ${{ steps.set-publish-version.outputs.VERSION }} |
| 34 | + VERSION: ${{ steps.set-staging-version.outputs.VERSION }} |
| 35 | + |
| 36 | + publish-npm-staging: |
| 37 | + # Only run for manual dispatch on main branch |
| 38 | + if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }} |
| 39 | + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected] |
| 40 | + needs: set-staging-version |
| 41 | + with: |
| 42 | + scope: '@iexec/dataprotector-deserializer' |
| 43 | + registry: 'https://registry.npmjs.org' |
| 44 | + node-version: '20' |
| 45 | + environment: 'staging' |
| 46 | + working-directory: packages/dataprotector-deserializer |
| 47 | + tag: 'nightly' |
| 48 | + version: ${{ needs.set-staging-version.outputs.VERSION }} |
40 | 49 |
|
41 | | - publish-npm: |
42 | | - # Run only on main branch |
43 | | - if: github.ref == 'refs/heads/main' |
44 | | - uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected] |
45 | | - needs: set-publish-version |
| 50 | + publish-npm-latest: |
| 51 | + # # Only run for release published with tag "dataprotector-deserializer-v*" |
| 52 | + if: ${{ github.event_name == 'release' && startsWith(github.ref_name,'dataprotector-deserializer-v') }} |
| 53 | + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected] |
46 | 54 | with: |
47 | | - scope: '@iexec/deserializer' |
| 55 | + scope: '@iexec/dataprotector-deserializer' |
48 | 56 | registry: 'https://registry.npmjs.org' |
49 | | - node-version: '18' |
50 | | - tag: ${{ github.event.inputs.tag }} |
51 | | - environment: production |
| 57 | + node-version: '20' |
52 | 58 | working-directory: packages/dataprotector-deserializer |
53 | | - version: ${{ needs.set-publish-version.outputs.VERSION }} |
54 | | - install-command: | |
55 | | - npm ci |
56 | | - cd ../sdk |
57 | | - npm ci |
58 | | - npm run codegen |
59 | | - npm run build |
60 | | - cd ../dataprotector-deserializer |
61 | | - npm run test:prepare |
62 | | - secrets: |
63 | | - npm-token: ${{ secrets.NPM_TOKEN }} |
| 59 | + tag: 'latest' |
0 commit comments