|
1 | | -# .github/workflows/auto-release.yml |
2 | | -name: Auto Release |
3 | | - |
4 | | -on: |
5 | | - push: |
6 | | - branches: [main] |
7 | | - |
8 | | -permissions: |
9 | | - contents: write |
10 | | - packages: write |
11 | | - |
12 | | -jobs: |
13 | | - test: |
14 | | - runs-on: ubuntu-latest |
15 | | - steps: |
16 | | - - uses: actions/checkout@v4 |
17 | | - |
18 | | - - name: Setup pnpm |
19 | | - uses: pnpm/action-setup@v2 |
20 | | - with: |
21 | | - version: 9 |
22 | | - |
23 | | - - name: Setup Node.js |
24 | | - uses: actions/setup-node@v4 |
25 | | - with: |
26 | | - node-version: "18" |
27 | | - cache: "pnpm" |
28 | | - |
29 | | - - name: Install dependencies |
30 | | - run: pnpm install --frozen-lockfile |
31 | | - |
32 | | - - name: Run tests |
33 | | - run: pnpm test |
34 | | - |
35 | | - - name: Run linter |
36 | | - run: pnpm run lint || echo "No lint script" |
37 | | - |
38 | | - - name: Build package |
39 | | - run: pnpm run build |
40 | | - |
41 | | - - name: Check package |
42 | | - run: pnpm pack && rm -f *.tgz |
43 | | - |
44 | | - auto-release: |
45 | | - needs: test |
46 | | - runs-on: ubuntu-latest |
47 | | - steps: |
48 | | - - uses: actions/checkout@v4 |
49 | | - with: |
50 | | - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} |
51 | | - fetch-depth: 0 |
52 | | - |
53 | | - - name: Setup pnpm |
54 | | - uses: pnpm/action-setup@v2 |
55 | | - with: |
56 | | - version: 9 |
57 | | - |
58 | | - - name: Setup Node.js |
59 | | - uses: actions/setup-node@v4 |
60 | | - with: |
61 | | - node-version: "18" |
62 | | - registry-url: "https://registry.npmjs.org" |
63 | | - cache: "pnpm" |
64 | | - |
65 | | - - name: Install dependencies |
66 | | - run: pnpm install --frozen-lockfile |
67 | | - |
68 | | - - name: Build package |
69 | | - run: pnpm run build |
70 | | - |
71 | | - - name: Configure Git |
72 | | - run: | |
73 | | - git config --local user.email "action@github.com" |
74 | | - git config --local user.name "GitHub Action" |
75 | | -
|
76 | | - - name: Determine version bump type |
77 | | - id: bump_type |
78 | | - run: | |
79 | | - # Get the last commit message |
80 | | - COMMIT_MSG=$(git log -1 --pretty=%B) |
81 | | - echo "Commit message: $COMMIT_MSG" |
82 | | -
|
83 | | - # Determine bump type based on commit message |
84 | | - if echo "$COMMIT_MSG" | grep -iq "BREAKING CHANGE\|major:"; then |
85 | | - echo "type=major" >> $GITHUB_OUTPUT |
86 | | - echo "Detected MAJOR version bump" |
87 | | - elif echo "$COMMIT_MSG" | grep -iq "feat:\|feature:\|minor:"; then |
88 | | - echo "type=minor" >> $GITHUB_OUTPUT |
89 | | - echo "Detected MINOR version bump" |
90 | | - else |
91 | | - echo "type=patch" >> $GITHUB_OUTPUT |
92 | | - echo "Detected PATCH version bump" |
93 | | - fi |
94 | | -
|
95 | | - - name: Check if version already bumped |
96 | | - id: check_version |
97 | | - run: | |
98 | | - CURRENT_VERSION=$(node -p "require('./package.json').version") |
99 | | - echo "Current version: $CURRENT_VERSION" |
100 | | -
|
101 | | - # Check if tag already exists |
102 | | - if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then |
103 | | - echo "Tag v$CURRENT_VERSION already exists" |
104 | | - echo "needs_bump=true" >> $GITHUB_OUTPUT |
105 | | - else |
106 | | - echo "Tag v$CURRENT_VERSION does not exist" |
107 | | - echo "needs_bump=false" >> $GITHUB_OUTPUT |
108 | | - echo "VERSION=$CURRENT_VERSION" >> $GITHUB_ENV |
109 | | - fi |
110 | | -
|
111 | | - - name: Bump version in package.json |
112 | | - if: steps.check_version.outputs.needs_bump == 'true' |
113 | | - run: | |
114 | | - pnpm version ${{ steps.bump_type.outputs.type }} -m "chore: release v%s [skip ci]" |
115 | | - NEW_VERSION=$(node -p "require('./package.json').version") |
116 | | - echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV |
117 | | - echo "Bumped to version $NEW_VERSION" |
118 | | -
|
119 | | - - name: Push version bump commit |
120 | | - if: steps.check_version.outputs.needs_bump == 'true' |
121 | | - run: | |
122 | | - git push origin main |
123 | | -
|
124 | | - - name: Create and push tag |
125 | | - run: | |
126 | | - git tag v${{ env.VERSION }} |
127 | | - git push origin v${{ env.VERSION }} |
128 | | - echo "Created and pushed tag v${{ env.VERSION }}" |
129 | | -
|
130 | | - - name: Generate changelog and update file |
131 | | - run: | |
132 | | - # Install changelog generator |
133 | | - npm install -g auto-changelog |
134 | | -
|
135 | | - # Generate changelog content using the custom template |
136 | | - auto-changelog --stdout --commit-limit false -u --template ".github/changelog-template.hbs" --starting-version ${{ env.VERSION }} --issue-url "https://github.com/canadianeagle/vite-plugin-component-debugger/issues/{id}" > new-changelog-entry.md |
137 | | -
|
138 | | - # Prepare the new changelog entry |
139 | | - # The output from auto-changelog includes the version header, so we can use it directly |
140 | | -
|
141 | | - # Read the existing changelog |
142 | | - EXISTING_CHANGELOG=$(cat changelog.md) |
143 | | -
|
144 | | - # Create the new changelog content |
145 | | - # The header is already in new-changelog-entry.md |
146 | | - # We need to remove the old header from the existing changelog |
147 | | - # This is a simple way to do it, might need adjustment based on your changelog format |
148 | | - UPDATED_CHANGELOG=$(echo -e "$(cat new-changelog-entry.md)\n\n$(echo "$EXISTING_CHANGELOG" | sed '1,7d')") |
149 | | -
|
150 | | - # Write the updated changelog |
151 | | - echo "$UPDATED_CHANGELOG" > changelog.md |
152 | | -
|
153 | | - # Also create release notes for the GitHub Release |
154 | | - cp changelog.md release-notes.md |
155 | | -
|
156 | | - # Commit the updated changelog |
157 | | - git add changelog.md |
158 | | - git commit -m "chore: update changelog for v${{ env.VERSION }} [skip ci]" |
159 | | - git push origin main |
160 | | -
|
161 | | - - name: Create GitHub Release |
162 | | - id: create_release |
163 | | - uses: actions/create-release@v1 |
164 | | - env: |
165 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
166 | | - with: |
167 | | - tag_name: v${{ env.VERSION }} |
168 | | - release_name: v${{ env.VERSION }} |
169 | | - body_path: release-notes.md |
170 | | - draft: false |
171 | | - prerelease: false |
172 | | - |
173 | | - - name: Publish to NPM |
174 | | - run: pnpm publish --access public --no-git-checks |
175 | | - env: |
176 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
177 | | - |
178 | | - - name: Success notification |
179 | | - run: | |
180 | | - echo "🎉 Successfully released v${{ env.VERSION }}" |
181 | | - echo "📦 NPM: https://www.npmjs.com/package/vite-plugin-component-debugger" |
182 | | - echo "🏷️ GitHub: ${{ steps.create_release.outputs.html_url }}" |
| 1 | +# .github/workflows/auto-release.yml |
| 2 | +name: Auto Release |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + packages: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup pnpm |
| 19 | + uses: pnpm/action-setup@v2 |
| 20 | + with: |
| 21 | + version: 9 |
| 22 | + |
| 23 | + - name: Setup Node.js |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: "18" |
| 27 | + cache: "pnpm" |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: pnpm install --frozen-lockfile |
| 31 | + |
| 32 | + - name: Run tests |
| 33 | + run: pnpm test |
| 34 | + |
| 35 | + - name: Run linter |
| 36 | + run: pnpm run lint || echo "No lint script" |
| 37 | + |
| 38 | + - name: Build package |
| 39 | + run: pnpm run build |
| 40 | + |
| 41 | + - name: Check package |
| 42 | + run: pnpm pack && rm -f *.tgz |
| 43 | + |
| 44 | + auto-release: |
| 45 | + needs: test |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + with: |
| 50 | + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} |
| 51 | + fetch-depth: 0 |
| 52 | + |
| 53 | + - name: Setup pnpm |
| 54 | + uses: pnpm/action-setup@v2 |
| 55 | + with: |
| 56 | + version: 9 |
| 57 | + |
| 58 | + - name: Setup Node.js |
| 59 | + uses: actions/setup-node@v4 |
| 60 | + with: |
| 61 | + node-version: "18" |
| 62 | + registry-url: "https://registry.npmjs.org" |
| 63 | + cache: "pnpm" |
| 64 | + |
| 65 | + - name: Install dependencies |
| 66 | + run: pnpm install --frozen-lockfile |
| 67 | + |
| 68 | + - name: Build package |
| 69 | + run: pnpm run build |
| 70 | + |
| 71 | + - name: Configure Git |
| 72 | + run: | |
| 73 | + git config --local user.email "action@github.com" |
| 74 | + git config --local user.name "GitHub Action" |
| 75 | +
|
| 76 | + - name: Determine version bump type |
| 77 | + id: bump_type |
| 78 | + run: | |
| 79 | + # Get the last commit message |
| 80 | + COMMIT_MSG=$(git log -1 --pretty=%B) |
| 81 | + echo "Commit message: $COMMIT_MSG" |
| 82 | +
|
| 83 | + # Determine bump type based on commit message |
| 84 | + if echo "$COMMIT_MSG" | grep -iq "BREAKING CHANGE\|major:"; then |
| 85 | + echo "type=major" >> $GITHUB_OUTPUT |
| 86 | + echo "Detected MAJOR version bump" |
| 87 | + elif echo "$COMMIT_MSG" | grep -iq "feat:\|feature:\|minor:"; then |
| 88 | + echo "type=minor" >> $GITHUB_OUTPUT |
| 89 | + echo "Detected MINOR version bump" |
| 90 | + else |
| 91 | + echo "type=patch" >> $GITHUB_OUTPUT |
| 92 | + echo "Detected PATCH version bump" |
| 93 | + fi |
| 94 | +
|
| 95 | + - name: Check if version already bumped |
| 96 | + id: check_version |
| 97 | + run: | |
| 98 | + CURRENT_VERSION=$(node -p "require('./package.json').version") |
| 99 | + echo "Current version: $CURRENT_VERSION" |
| 100 | +
|
| 101 | + # Check if tag already exists |
| 102 | + if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then |
| 103 | + echo "Tag v$CURRENT_VERSION already exists" |
| 104 | + echo "needs_bump=true" >> $GITHUB_OUTPUT |
| 105 | + else |
| 106 | + echo "Tag v$CURRENT_VERSION does not exist" |
| 107 | + echo "needs_bump=false" >> $GITHUB_OUTPUT |
| 108 | + echo "VERSION=$CURRENT_VERSION" >> $GITHUB_ENV |
| 109 | + fi |
| 110 | +
|
| 111 | + - name: Bump version in package.json |
| 112 | + if: steps.check_version.outputs.needs_bump == 'true' |
| 113 | + run: | |
| 114 | + pnpm version ${{ steps.bump_type.outputs.type }} -m "chore: release v%s [skip ci]" |
| 115 | + NEW_VERSION=$(node -p "require('./package.json').version") |
| 116 | + echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV |
| 117 | + echo "Bumped to version $NEW_VERSION" |
| 118 | +
|
| 119 | + - name: Push version bump commit |
| 120 | + if: steps.check_version.outputs.needs_bump == 'true' |
| 121 | + run: | |
| 122 | + git push origin main |
| 123 | +
|
| 124 | + - name: Create and push tag |
| 125 | + run: | |
| 126 | + git tag v${{ env.VERSION }} |
| 127 | + git push origin v${{ env.VERSION }} |
| 128 | + echo "Created and pushed tag v${{ env.VERSION }}" |
| 129 | +
|
| 130 | + - name: Generate changelog and update file |
| 131 | + run: | |
| 132 | + # Install changelog generator |
| 133 | + npm install -g auto-changelog |
| 134 | +
|
| 135 | + # Generate changelog content using the custom template |
| 136 | + auto-changelog --stdout --commit-limit false -u --template ".github/changelog-template.hbs" --starting-version ${{ env.VERSION }} --issue-url "https://github.com/canadianeagle/vite-plugin-component-debugger/issues/{id}" > new-changelog-entry.md |
| 137 | +
|
| 138 | + # Prepare the new changelog entry |
| 139 | + # The output from auto-changelog includes the version header, so we can use it directly |
| 140 | +
|
| 141 | + # Read the existing changelog |
| 142 | + EXISTING_CHANGELOG=$(cat changelog.md) |
| 143 | +
|
| 144 | + # Create the new changelog content |
| 145 | + # The header is already in new-changelog-entry.md |
| 146 | + # We need to remove the old header from the existing changelog |
| 147 | + # This is a simple way to do it, might need adjustment based on your changelog format |
| 148 | + UPDATED_CHANGELOG=$(echo -e "$(cat new-changelog-entry.md)\n\n$(echo "$EXISTING_CHANGELOG" | sed '1,7d')") |
| 149 | +
|
| 150 | + # Write the updated changelog |
| 151 | + echo "$UPDATED_CHANGELOG" > changelog.md |
| 152 | +
|
| 153 | + # Also create release notes for the GitHub Release |
| 154 | + cp changelog.md release-notes.md |
| 155 | +
|
| 156 | + # Commit the updated changelog |
| 157 | + git add changelog.md |
| 158 | + git commit -m "chore: update changelog for v${{ env.VERSION }} [skip ci]" |
| 159 | + git push origin main |
| 160 | +
|
| 161 | + - name: Create GitHub Release |
| 162 | + id: create_release |
| 163 | + uses: actions/create-release@v1 |
| 164 | + env: |
| 165 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 166 | + with: |
| 167 | + tag_name: v${{ env.VERSION }} |
| 168 | + release_name: v${{ env.VERSION }} |
| 169 | + body_path: release-notes.md |
| 170 | + draft: false |
| 171 | + prerelease: false |
| 172 | + |
| 173 | + - name: Publish to NPM |
| 174 | + run: pnpm publish --access public --no-git-checks |
| 175 | + env: |
| 176 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 177 | + |
| 178 | + - name: Success notification |
| 179 | + run: | |
| 180 | + echo "🎉 Successfully released v${{ env.VERSION }}" |
| 181 | + echo "📦 NPM: https://www.npmjs.com/package/vite-plugin-component-debugger" |
| 182 | + echo "🏷️ GitHub: ${{ steps.create_release.outputs.html_url }}" |
0 commit comments