|
1 |
| -name: release |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - main
|
7 |
| - workflow_dispatch: |
8 |
| - inputs: |
9 |
| - version: |
10 |
| - description: "Version to tag (e.g., 3.0.3)" |
11 |
| - required: true |
12 |
| - type: string |
13 | 7 |
|
14 |
| -permissions: |
15 |
| - contents: read |
| 8 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
16 | 9 |
|
17 | 10 | jobs:
|
18 | 11 | release:
|
19 | 12 | name: Release
|
20 | 13 | runs-on: ubuntu-latest
|
21 | 14 | permissions:
|
22 |
| - contents: write # to be able to publish a GitHub release |
23 |
| - issues: write # to be able to comment on released issues |
24 |
| - pull-requests: write # to be able to comment on released pull requests |
25 |
| - id-token: write # to enable use of OIDC for npm provenance |
26 |
| - |
| 15 | + contents: write # to create release (changesets/action) |
| 16 | + issues: write # to post issue comments (changesets/action) |
| 17 | + pull-requests: write # to create pull request (changesets/action) |
27 | 18 | steps:
|
28 |
| - - uses: actions/checkout@v4 |
29 |
| - with: |
30 |
| - fetch-depth: 0 |
31 |
| - |
32 |
| - - name: Setup Git |
33 |
| - if: github.event_name == 'workflow_dispatch' |
34 |
| - run: | |
35 |
| - git config --global user.name 'GitHub Action' |
36 |
| - git config --global user.email 'action@github.com' |
37 |
| - git tag -a v${{ inputs.version }} -m "v${{ inputs.version }}" |
38 |
| - git push origin v${{ inputs.version }} |
| 19 | + - name: Checkout Repo |
| 20 | + uses: actions/checkout@v4 |
39 | 21 |
|
40 |
| - - name: Install pnpm |
41 |
| - uses: pnpm/action-setup@v4 |
| 22 | + - name: Setup pnpm 8 |
| 23 | + uses: pnpm/action-setup@v3 |
42 | 24 | with:
|
43 |
| - version: 9 |
44 |
| - run_install: false |
| 25 | + version: 8 |
45 | 26 |
|
46 |
| - - uses: actions/setup-node@v4 |
| 27 | + - name: Setup Node.js 20.x |
| 28 | + uses: actions/setup-node@v4 |
47 | 29 | with:
|
48 |
| - node-version-file: ".nvmrc" |
49 |
| - cache: "pnpm" |
| 30 | + node-version: 20.x |
50 | 31 |
|
51 |
| - - name: Install dependencies |
52 |
| - run: pnpm install --frozen-lockfile # Install dependencies with lockfile's versions to ensure consistency |
| 32 | + - name: Install Dependencies |
| 33 | + run: pnpm i |
53 | 34 |
|
54 |
| - - name: Cache Build |
55 |
| - id: cache-build |
56 |
| - uses: actions/cache@v4 |
| 35 | + - name: Create Release Pull Request or Publish to npm |
| 36 | + id: changesets |
| 37 | + uses: changesets/action@v1 |
57 | 38 | with:
|
58 |
| - path: dist |
59 |
| - key: ${{ runner.os }}-build-${{ hashFiles('**/*.ts', '**/*.tsx', '**/*.mdx') }} # Cache key based on OS and file hashes |
60 |
| - restore-keys: | |
61 |
| - ${{ runner.os }}-build- |
62 |
| -
|
63 |
| - - name: Build |
64 |
| - if: steps.cache-build.outputs.cache-hit != 'true' |
65 |
| - run: pnpm build |
66 |
| - |
67 |
| - - name: Semantic Release |
68 |
| - run: pnpx semantic-release |
| 39 | + publish: pnpm release |
| 40 | + version: pnpm version-packages |
| 41 | + commit: "ci: new release" |
| 42 | + title: "ci: new release candidate" |
69 | 43 | env:
|
70 |
| - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
71 | 45 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
| 46 | + |
| 47 | + # - name: Send a Slack notification if a publish happens |
| 48 | + # if: steps.changesets.outputs.published == 'true' |
| 49 | + # # You can do something when a publish happens. |
| 50 | + # run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!" |
0 commit comments