|
| 1 | +name: Release and Publish |
| 2 | + |
1 | 3 | on:
|
2 | 4 | push:
|
3 | 5 | branches:
|
4 |
| - - main |
5 |
| -name: release-please |
6 |
| -permissions: { } |
| 6 | + - main # Trigger on push to the main branch |
| 7 | + |
7 | 8 | jobs:
|
8 |
| - release-please: |
| 9 | + release: |
| 10 | + name: Automated Release with NPM Publish |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
9 | 13 | permissions:
|
10 |
| - contents: write # to create release commit (google-github-actions/release-please-action) |
11 |
| - pull-requests: write # to create release PR (google-github-actions/release-please-action) |
| 14 | + contents: write |
| 15 | + issues: write |
| 16 | + pull-requests: write |
| 17 | + |
| 18 | + steps: |
| 19 | + # Step 1: Checkout the repository |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v3 |
| 22 | + |
| 23 | + # Step 2: Set up Node.js environment |
| 24 | + - name: Set up Node.js |
| 25 | + uses: actions/setup-node@v3 |
| 26 | + with: |
| 27 | + node-version: '22' # Specify Node.js version |
| 28 | + cache: 'yarn' # Use Yarn and cache dependencies |
| 29 | + |
| 30 | + # Step 3: Install dependencies with Yarn |
| 31 | + - name: Install dependencies |
| 32 | + run: yarn install |
| 33 | + |
| 34 | + # Step 4: Run tests (optional) |
| 35 | + - name: Run tests |
| 36 | + run: yarn test |
12 | 37 |
|
| 38 | + # Step 5: Build the project (optional) |
| 39 | + - name: Build project |
| 40 | + run: yarn build |
| 41 | + |
| 42 | + # Step 6: Use Release Please to automatically create a release |
| 43 | + - name: Release Please |
| 44 | + uses: google-github-actions/release-please-action@v4 |
| 45 | + with: |
| 46 | + release-type: node # Can be node, npm, or based on your project type |
| 47 | + package-name: lit-functions |
| 48 | + token: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub automatically |
| 49 | + |
| 50 | + publish: |
| 51 | + name: Publish to npm |
| 52 | + needs: release |
13 | 53 | runs-on: ubuntu-latest
|
| 54 | + |
14 | 55 | steps:
|
15 |
| - - uses: google-github-actions/release-please-action@v4 |
16 |
| - id: release |
17 |
| - with: |
18 |
| - token: ${{ secrets.GITHUB_TOKEN }} |
19 |
| - release-type: node |
20 |
| - - uses: actions/checkout@v4 |
21 |
| - - uses: actions/setup-node@v3 |
22 |
| - if: ${{ steps.release.outputs.release_created }} |
| 56 | + # Step 1: Checkout the repository |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v3 |
| 59 | + |
| 60 | + # Step 2: Set up Node.js environment |
| 61 | + - name: Set up Node.js |
| 62 | + uses: actions/setup-node@v3 |
23 | 63 | with:
|
24 |
| - node-version: 22 |
25 |
| - registry-url: https://registry.npmjs.org/ |
26 |
| - - run: yarn |
27 |
| - if: ${{ steps.release.outputs.release_created }} |
28 |
| - - run: yarn workspace lit-functions publish |
29 |
| - if: ${{ steps.release.outputs.release_created }} |
| 64 | + node-version: '22' # Specify Node.js version |
| 65 | + cache: 'yarn' # Use Yarn and cache dependencies |
| 66 | + |
| 67 | + # Step 3: Install dependencies with Yarn |
| 68 | + - name: Install dependencies |
| 69 | + run: yarn install |
| 70 | + |
| 71 | + # Step 4: Publish to npm |
| 72 | + - name: Publish to npm |
| 73 | + run: yarn publish --non-interactive --access public |
30 | 74 | env:
|
31 |
| - NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
| 75 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 76 | + |
0 commit comments