|
1 | | -name: Publish to npm |
| 1 | +name: Build and Publish |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [main] |
6 | | - tags: |
7 | | - - 'v*' |
| 6 | + tags: ['v*'] |
8 | 7 | workflow_dispatch: |
9 | 8 |
|
10 | 9 | jobs: |
11 | | - publish: |
| 10 | + build: |
12 | 11 | runs-on: ubuntu-latest |
13 | | - permissions: |
14 | | - contents: read |
15 | | - id-token: write |
16 | | - |
17 | 12 | steps: |
18 | | - - name: Checkout |
19 | | - uses: actions/checkout@v4 |
20 | | - |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
21 | 15 | - name: Setup Node.js |
22 | 16 | uses: actions/setup-node@v4 |
23 | 17 | with: |
24 | 18 | node-version: '20' |
25 | | - registry-url: 'https://registry.npmjs.org' |
26 | 19 |
|
27 | 20 | - name: Install dependencies |
28 | 21 | run: npm ci |
29 | 22 |
|
30 | 23 | - name: Build |
31 | 24 | run: npm run build |
32 | | - |
33 | | - - name: Extract version |
34 | | - id: version |
35 | | - run: | |
36 | | - VERSION=$(node -p "require('./package.json').version") |
37 | | - echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
38 | | - echo "Found version: $VERSION" |
39 | | - |
40 | | - - name: Check version tag |
41 | | - id: check-tag |
42 | | - run: | |
43 | | - TAG_VERSION="v${{ steps.version.outputs.VERSION }}" |
44 | | - echo "Checking for tag: $TAG_VERSION" |
45 | | - if git rev-parse "refs/tags/$TAG_VERSION" > /dev/null 2>&1; then |
46 | | - echo "tag_exists=true" >> $GITHUB_OUTPUT |
47 | | - echo "Tag exists, will publish" |
48 | | - else |
49 | | - echo "tag_exists=false" >> $GITHUB_OUTPUT |
50 | | - echo "Tag does not exist, skipping publish" |
51 | | - fi |
| 25 | + env: |
| 26 | + CI: true |
| 27 | + |
| 28 | + - name: Upload build artifact |
| 29 | + uses: actions/upload-artifact@v4 |
| 30 | + with: |
| 31 | + name: dist |
| 32 | + path: dist/ |
| 33 | + |
| 34 | + publish: |
| 35 | + needs: build |
| 36 | + runs-on: ubuntu-latest |
| 37 | + if: startsWith(github.ref, 'refs/tags/v') |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Download artifact |
| 42 | + uses: actions/download-artifact@v4 |
| 43 | + with: |
| 44 | + name: dist |
| 45 | + path: dist/ |
| 46 | + |
| 47 | + - name: Setup Node.js |
| 48 | + uses: actions/setup-node@v4 |
| 49 | + with: |
| 50 | + node-version: '20' |
| 51 | + registry-url: 'https://registry.npmjs.org' |
52 | 52 |
|
53 | | - - name: Publish to npm (on tag) |
54 | | - if: steps.check-tag.outputs.tag_exists == 'true' |
| 53 | + - name: Publish to npm |
55 | 54 | run: npm publish --access public |
56 | 55 | env: |
57 | 56 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
58 | 57 |
|
59 | | - - name: Create Release (on tag) |
60 | | - if: steps.check-tag.outputs.tag_exists == 'true' |
| 58 | + - name: Create GitHub Release |
61 | 59 | uses: actions/create-release@v1 |
62 | 60 | env: |
63 | 61 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
64 | 62 | with: |
65 | | - tag_name: v${{ steps.version.outputs.VERSION }} |
66 | | - release_name: TaskFlow AI v${{ steps.version.outputs.VERSION }} |
| 63 | + tag_name: ${{ github.ref }} |
| 64 | + release_name: TaskFlow AI ${{ github.ref }} |
67 | 65 | draft: false |
68 | 66 | prerelease: false |
0 commit comments