|
1 | | -name: Publish |
2 | | - |
3 | | -on: |
4 | | - workflow_run: |
5 | | - workflows: ["CI"] |
6 | | - types: |
7 | | - - completed |
8 | | - branches: |
9 | | - - main |
10 | | - |
11 | | -jobs: |
12 | | - publish: |
13 | | - runs-on: ubuntu-latest |
14 | | - # Only run if CI workflow succeeded and the last commit was not made by GitHub Actions |
15 | | - if: > |
16 | | - github.event.workflow_run.conclusion == 'success' && |
17 | | - github.event.workflow_run.head_commit.author.email != 'action@github.com' && |
18 | | - !contains(github.event.workflow_run.head_commit.message, '[skip publish]') |
19 | | -
|
20 | | - steps: |
21 | | - - name: Checkout |
22 | | - uses: actions/checkout@v4 |
23 | | - with: |
24 | | - # Use a token that can push to protected branches |
25 | | - token: ${{ secrets.GITHUB_TOKEN }} |
26 | | - fetch-depth: 0 |
27 | | - |
28 | | - - name: Setup Node.js |
29 | | - uses: actions/setup-node@v4 |
30 | | - with: |
31 | | - node-version: "22" |
32 | | - cache: "npm" |
33 | | - registry-url: "https://registry.npmjs.org" |
34 | | - |
35 | | - - name: Install dependencies |
36 | | - run: npm ci |
37 | | - |
38 | | - - name: Configure Git |
39 | | - run: | |
40 | | - git config --local user.email "action@github.com" |
41 | | - git config --local user.name "GitHub Action" |
42 | | -
|
43 | | - - name: Bump version |
44 | | - run: | |
45 | | - # Get current version |
46 | | - CURRENT_VERSION=$(node -p "require('./package.json').version") |
47 | | - echo "Current version: $CURRENT_VERSION" |
48 | | - |
49 | | - # Bump patch version |
50 | | - npm version patch --no-git-tag-version |
51 | | - |
52 | | - # Get new version |
53 | | - NEW_VERSION=$(node -p "require('./package.json').version") |
54 | | - echo "New version: $NEW_VERSION" |
55 | | - |
56 | | - # Commit the version bump |
57 | | - git add package.json |
58 | | - git commit -m "chore: bump version to $NEW_VERSION [skip publish]" |
59 | | - |
60 | | - # Push the changes |
61 | | - git push origin main |
62 | | -
|
63 | | - - name: Build |
64 | | - run: npm run build |
65 | | - |
66 | | - - name: Publish to NPM |
67 | | - run: npm publish |
68 | | - env: |
69 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 1 | +name: Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["CI"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + publish: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + # Only run if CI workflow succeeded and the last commit was not made by GitHub Actions |
| 15 | + if: > |
| 16 | + github.event.workflow_run.conclusion == 'success' && |
| 17 | + github.event.workflow_run.head_commit.author.email != 'action@github.com' && |
| 18 | + !contains(github.event.workflow_run.head_commit.message, '[skip publish]') |
| 19 | +
|
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + # Use a token that can push to protected branches |
| 25 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - name: Setup Node.js |
| 29 | + uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: "22" |
| 32 | + cache: "npm" |
| 33 | + registry-url: "https://registry.npmjs.org" |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: npm ci |
| 37 | + |
| 38 | + - name: Configure Git |
| 39 | + run: | |
| 40 | + git config --local user.email "action@github.com" |
| 41 | + git config --local user.name "GitHub Action" |
| 42 | +
|
| 43 | + - name: Bump version |
| 44 | + run: | |
| 45 | + # Get current version |
| 46 | + CURRENT_VERSION=$(node -p "require('./package.json').version") |
| 47 | + echo "Current version: $CURRENT_VERSION" |
| 48 | +
|
| 49 | + # Bump patch version |
| 50 | + npm version patch --no-git-tag-version |
| 51 | +
|
| 52 | + # Get new version |
| 53 | + NEW_VERSION=$(node -p "require('./package.json').version") |
| 54 | + echo "New version: $NEW_VERSION" |
| 55 | +
|
| 56 | + # Commit the version bump |
| 57 | + git add package.json |
| 58 | + git commit -m "chore: bump version to $NEW_VERSION [skip publish]" |
| 59 | +
|
| 60 | + # Push the changes |
| 61 | + git push origin main |
| 62 | +
|
| 63 | + - name: Build |
| 64 | + run: npm run build |
| 65 | + |
| 66 | + - name: Publish to NPM |
| 67 | + run: npm publish |
| 68 | + env: |
| 69 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments