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