|
7 | 7 | - master |
8 | 8 | # A release via GitHub releases will deploy a latest version |
9 | 9 | release: |
10 | | - types: [ published ] |
| 10 | + types: [published] |
| 11 | + |
| 12 | +# Necessary permissions for publishing to NPM with OIDC |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + id-token: write |
11 | 16 |
|
12 | 17 | jobs: |
13 | | - # NPM install is done in a separate job and cached to speed up the following jobs. |
14 | | - build_and_test: |
15 | | - name: Build & Test |
16 | | - if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} |
17 | | - runs-on: ${{ matrix.os }} |
| 18 | + lint_and_test: |
| 19 | + name: Lint and test |
| 20 | + uses: ./.github/workflows/check.yaml |
18 | 21 |
|
19 | | - strategy: |
20 | | - matrix: |
21 | | - os: [ubuntu-22.04] # add windows-latest later |
22 | | - node-version: [14, 16, 18] |
| 22 | + deploy: |
| 23 | + name: Publish to NPM |
| 24 | + needs: [lint_and_test] |
| 25 | + runs-on: ubuntu-22.04 |
23 | 26 |
|
24 | 27 | steps: |
25 | | - - |
26 | | - uses: actions/checkout@v2 |
27 | | - - |
28 | | - name: Use Node.js ${{ matrix.node-version }} |
29 | | - uses: actions/setup-node@v1 |
30 | | - with: |
31 | | - node-version: ${{ matrix.node-version }} |
32 | | - - |
33 | | - name: Cache Node Modules |
34 | | - if: ${{ matrix.node-version == 18 }} |
35 | | - uses: actions/cache@v4 |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v6 |
| 30 | + |
| 31 | + - name: Use Node.js 24 |
| 32 | + uses: actions/setup-node@v6 |
36 | 33 | with: |
37 | | - path: | |
38 | | - node_modules |
39 | | - build |
40 | | - key: cache-${{ github.run_id }}-v18 |
41 | | - - |
42 | | - name: Install Dependencies |
| 34 | + node-version: 24 |
| 35 | + |
| 36 | + - name: Install dependencies |
43 | 37 | run: npm install |
44 | | - - name: Add localhost-test to Linux hosts file |
45 | | - if: ${{ matrix.os == 'ubuntu-22.04' }} |
46 | | - run: sudo echo "127.0.0.1 localhost-test" | sudo tee -a /etc/hosts |
47 | | -# - |
48 | | -# name: Add localhost-test to Windows hosts file |
49 | | -# if: ${{ matrix.os == 'windows-latest' }} |
50 | | -# run: echo "`n127.0.0.1 localhost-test">>C:\Windows\System32\drivers\etc\hosts |
51 | | - - |
52 | | - name: Run Tests |
53 | | - run: npm test |
54 | 38 |
|
55 | | - lint: |
56 | | - name: Lint |
57 | | - needs: [build_and_test] |
58 | | - runs-on: ubuntu-22.04 |
| 39 | + # Determine if this is a beta or latest release |
| 40 | + - name: Get release tag |
| 41 | + id: get_release_tag |
| 42 | + run: echo "release_tag=$(if [ ${{ github.event_name }} = release ]; then echo latest; else echo beta; fi)" >> $GITHUB_OUTPUT |
59 | 43 |
|
60 | | - steps: |
61 | | - - |
62 | | - uses: actions/checkout@v2 |
63 | | - - |
64 | | - name: Use Node.js 18 |
65 | | - uses: actions/setup-node@v1 |
66 | | - with: |
67 | | - node-version: 18 |
68 | | - - |
69 | | - name: Load Cache |
70 | | - uses: actions/cache@v4 |
71 | | - with: |
72 | | - path: | |
73 | | - node_modules |
74 | | - build |
75 | | - key: cache-${{ github.run_id }}-v18 |
76 | | - - |
77 | | - run: npm run lint |
| 44 | + # Check version consistency and increment pre-release version number for beta only. |
| 45 | + - name: Bump pre-release version |
| 46 | + if: steps.get_release_tag.outputs.release_tag == 'beta' |
| 47 | + run: node ./.github/scripts/before-beta-release.js |
78 | 48 |
|
| 49 | + - name: Publish to NPM |
| 50 | + run: npm publish --tag ${{ steps.get_release_tag.outputs.release_tag }} |
79 | 51 |
|
80 | | - # The deploy job is long but there are only 2 important parts. NPM publish |
81 | | - # and triggering of docker image builds in the apify-actor-docker repo. |
82 | | - deploy: |
83 | | - name: Publish to NPM |
84 | | - needs: [lint] |
85 | | - runs-on: ubuntu-22.04 |
86 | | - steps: |
87 | | - - |
88 | | - uses: actions/checkout@v2 |
89 | | - - |
90 | | - uses: actions/setup-node@v1 |
91 | | - with: |
92 | | - node-version: 18 |
93 | | - registry-url: https://registry.npmjs.org/ |
94 | | - - |
95 | | - name: Load Cache |
96 | | - uses: actions/cache@v4 |
97 | | - with: |
98 | | - path: | |
99 | | - node_modules |
100 | | - build |
101 | | - key: cache-${{ github.run_id }}-v18 |
102 | | - - |
103 | | - # Determine if this is a beta or latest release |
104 | | - name: Set Release Tag |
105 | | - run: echo "RELEASE_TAG=$(if [ ${{ github.event_name }} = release ]; then echo latest; else echo beta; fi)" >> $GITHUB_ENV |
106 | | - - |
107 | | - # Check version consistency and increment pre-release version number for beta only. |
108 | | - name: Bump pre-release version |
109 | | - if: env.RELEASE_TAG == 'beta' |
110 | | - run: node ./.github/scripts/before-beta-release.js |
111 | | - - |
112 | | - name: Publish to NPM |
113 | | - run: NODE_AUTH_TOKEN=${{secrets.NPM_TOKEN}} npm publish --tag ${{ env.RELEASE_TAG }} --access public |
114 | | - - |
115 | | - # Latest version is tagged by the release process so we only tag beta here. |
116 | | - name: Tag Version |
117 | | - if: env.RELEASE_TAG == 'beta' |
| 52 | + # Latest version is tagged by the release process so we only tag beta here. |
| 53 | + - name: Tag version |
| 54 | + if: steps.get_release_tag.outputs.release_tag == 'beta' |
118 | 55 | run: | |
119 | 56 | git_tag=v`node -p "require('./package.json').version"` |
120 | 57 | git tag $git_tag |
|
0 commit comments