|
1 | | -name: Create release from version bump |
| 1 | +name: Publish to NPM on Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - "v*" |
7 | 7 |
|
8 | 8 | permissions: |
9 | | - contents: write |
| 9 | + contents: read |
| 10 | + packages: write |
10 | 11 |
|
11 | 12 | jobs: |
12 | | - create-release: |
13 | | - name: Create GitHub Release |
14 | | - runs-on: ubuntu-latest |
15 | | - |
16 | | - steps: |
17 | | - - name: Checkout code |
18 | | - uses: actions/checkout@v4 |
19 | | - with: |
20 | | - fetch-depth: 2 |
21 | | - |
22 | | - - name: Extract version from tag |
23 | | - id: version_extract |
24 | | - run: | |
25 | | - # Remove 'v' prefix from tag name to get version |
26 | | - VERSION=${GITHUB_REF#refs/tags/v} |
27 | | - echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV |
28 | | - echo "Extracted version: $VERSION" |
29 | | -
|
30 | | - - name: Create Release |
31 | | - env: |
32 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
33 | | - run: | |
34 | | - echo "Debug information:" |
35 | | - echo "GITHUB_REF: $GITHUB_REF" |
36 | | - echo "GITHUB_REF_NAME: ${{ github.ref_name }}" |
37 | | - echo "GITHUB_REPOSITORY: ${{ github.repository }}" |
38 | | -
|
39 | | - # List all tags to see what exists |
40 | | - echo "Available tags:" |
41 | | - git tag -l |
42 | | -
|
43 | | - # Check if the specific tag exists |
44 | | - if git rev-parse "${{ github.ref_name }}" >/dev/null 2>&1; then |
45 | | - echo "Tag ${{ github.ref_name }} exists in git" |
46 | | - else |
47 | | - echo "Tag ${{ github.ref_name }} does NOT exist in git" |
48 | | - fi |
49 | | -
|
50 | | - # Try to create release with more verbose output |
51 | | - echo "Attempting to create release..." |
52 | | - gh release create "${{ github.ref_name }}" \ |
53 | | - --repo="${{ github.repository }}" \ |
54 | | - --title="Release ${{ github.ref_name }}" \ |
55 | | - --generate-notes \ |
56 | | - --verbose || { |
57 | | - echo "Release creation failed with exit code $?" |
58 | | - echo "Trying to get more details about existing releases..." |
59 | | - gh release list --repo="${{ github.repository }}" --limit=10 |
60 | | - exit 1 |
61 | | - } |
62 | | -
|
63 | 13 | publish-npm: |
64 | 14 | name: Publish to NPM |
65 | | - needs: create-release |
66 | 15 | runs-on: ubuntu-latest |
67 | | - permissions: |
68 | | - contents: read |
69 | | - packages: write |
70 | 16 | steps: |
71 | 17 | - uses: actions/checkout@v4 |
72 | 18 | - uses: actions/setup-node@v4 |
|
0 commit comments