|
8 | 8 | - '__tests__/**'
|
9 | 9 | - 'package.json'
|
10 | 10 | - 'yarn.lock'
|
11 |
| - - 'release.config.js' |
12 |
| - - '.github/workflows/ci.yml' |
13 | 11 | branches:
|
14 | 12 | - '*'
|
15 | 13 | - '**'
|
16 | 14 | - '!master'
|
17 | 15 |
|
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
18 | 20 | env:
|
19 | 21 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
20 | 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 23 | + DEVME_SDK_API_KEY: ${{ secrets.DEVME_SDK_API_KEY }} |
21 | 24 | CI: true
|
22 | 25 |
|
23 | 26 | jobs:
|
24 |
| - CI: |
| 27 | + test: |
| 28 | + name: Test |
25 | 29 | runs-on: ubuntu-latest
|
26 | 30 | timeout-minutes: 20
|
27 | 31 |
|
28 | 32 | permissions:
|
29 |
| - packages: write |
30 | 33 | contents: write
|
| 34 | + issues: write |
| 35 | + pull-requests: write |
| 36 | + id-token: write |
| 37 | + packages: write |
31 | 38 |
|
32 | 39 | steps:
|
33 |
| - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." |
34 |
| - |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v5 |
35 | 42 | with:
|
36 |
| - workflow_id: ci.yml |
37 |
| - access_token: ${{ github.token }} |
| 43 | + fetch-depth: 0 |
| 44 | + persist-credentials: false |
38 | 45 |
|
39 |
| - - uses: actions/checkout@v3 |
40 |
| - with: |
41 |
| - fetch-depth: 30 |
42 |
| - |
43 |
| - - uses: FranzDiebold/github-env-vars-action@v2 |
44 | 46 | - name: Setup Node.js
|
45 |
| - uses: actions/setup-node@v3 |
| 47 | + uses: actions/setup-node@v5 |
46 | 48 | with:
|
47 |
| - node-version: 19 |
| 49 | + node-version: 24 |
| 50 | + cache: 'yarn' |
48 | 51 |
|
49 |
| - - name: Yarn |
| 52 | + - name: Install dependencies |
50 | 53 | run: yarn install --frozen-lockfile
|
51 | 54 |
|
| 55 | + - name: Verify dependency integrity |
| 56 | + run: yarn audit || true |
| 57 | + |
| 58 | + - name: Lint |
| 59 | + run: yarn lint |
| 60 | + |
52 | 61 | - name: Test
|
| 62 | + run: yarn test |
| 63 | + |
| 64 | + - name: Build |
| 65 | + run: yarn build |
| 66 | + |
| 67 | + - name: Pre-release (develop branch only) |
| 68 | + id: semantic_release |
| 69 | + if: github.ref == 'refs/heads/develop' && github.event_name == 'push' |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 73 | + GIT_AUTHOR_NAME: DEV.ME Team |
| 74 | + GIT_AUTHOR_EMAIL: [email protected] |
| 75 | + GIT_COMMITTER_NAME: DEV.ME Team |
| 76 | + GIT_COMMITTER_EMAIL: [email protected] |
53 | 77 | run: |
|
54 |
| - yarn test |
| 78 | + # Install semantic-release and required plugins |
| 79 | + npm i -g semantic-release @semantic-release/git @semantic-release/github @semantic-release/changelog @semantic-release/npm @semantic-release/commit-analyzer |
| 80 | +
|
| 81 | + # Run semantic-release |
| 82 | + npx semantic-release --debug 2>&1 | tee release-output.txt |
55 | 83 |
|
56 |
| - - name: Release |
57 |
| - if: github.ref == 'refs/heads/develop' |
| 84 | + # Extract version and tag info from release output |
| 85 | + if grep -q "Published release" release-output.txt; then |
| 86 | + echo "release_published=true" >> $GITHUB_OUTPUT |
| 87 | + VERSION=$(grep -oP 'Published release \K[0-9]+\.[0-9]+\.[0-9]+(-.+)?' release-output.txt | head -1) |
| 88 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 89 | + echo "tag=v$VERSION" >> $GITHUB_OUTPUT |
| 90 | + else |
| 91 | + echo "release_published=false" >> $GITHUB_OUTPUT |
| 92 | + fi |
| 93 | +
|
| 94 | + - name: Add Release Summary |
| 95 | + if: always() |
58 | 96 | run: |
|
59 |
| - npm i -g semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits |
60 |
| - npx semantic-release --no-ci --debug |
| 97 | + echo "## 📦 Release Summary" >> $GITHUB_STEP_SUMMARY |
| 98 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 99 | +
|
| 100 | + if [[ "${{ steps.semantic_release.outputs.release_published }}" == "true" ]]; then |
| 101 | + echo "### ✅ Release Published Successfully!" >> $GITHUB_STEP_SUMMARY |
| 102 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 103 | + echo "- **Version:** \`${{ steps.semantic_release.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY |
| 104 | + echo "- **Tag:** \`${{ steps.semantic_release.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY |
| 105 | + echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY |
| 106 | + echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY |
| 107 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 108 | + echo "### 🔗 Links" >> $GITHUB_STEP_SUMMARY |
| 109 | + echo "- [NPM Package](https://www.npmjs.com/package/@devmehq/sdk-js/v/${{ steps.semantic_release.outputs.version }})" >> $GITHUB_STEP_SUMMARY |
| 110 | + echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.semantic_release.outputs.tag }})" >> $GITHUB_STEP_SUMMARY |
| 111 | + else |
| 112 | + echo "### ℹ️ No Release Published" >> $GITHUB_STEP_SUMMARY |
| 113 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 114 | + echo "No release was created. This could be because:" >> $GITHUB_STEP_SUMMARY |
| 115 | + echo "- No relevant commits found for release" >> $GITHUB_STEP_SUMMARY |
| 116 | + echo "- Commits don't follow conventional commit format" >> $GITHUB_STEP_SUMMARY |
| 117 | + echo "- Release conditions not met" >> $GITHUB_STEP_SUMMARY |
| 118 | + fi |
| 119 | +
|
| 120 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 121 | + echo "### 📊 Build Information" >> $GITHUB_STEP_SUMMARY |
| 122 | + echo "- **Workflow:** \`${{ github.workflow }}\`" >> $GITHUB_STEP_SUMMARY |
| 123 | + echo "- **Run ID:** \`${{ github.run_id }}\`" >> $GITHUB_STEP_SUMMARY |
| 124 | + echo "- **Run Number:** \`${{ github.run_number }}\`" >> $GITHUB_STEP_SUMMARY |
| 125 | + echo "- **Actor:** \`${{ github.actor }}\`" >> $GITHUB_STEP_SUMMARY |
| 126 | + echo "- **Event:** \`${{ github.event_name }}\`" >> $GITHUB_STEP_SUMMARY |
0 commit comments