|
11 | 11 | jobs: |
12 | 12 | build: |
13 | 13 | runs-on: ubuntu-22.04 |
| 14 | + permissions: |
| 15 | + issues: write |
14 | 16 | concurrency: |
15 | 17 | group: release-${{ github.ref }} |
16 | 18 | cancel-in-progress: true |
|
52 | 54 | env: |
53 | 55 | CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} |
54 | 56 | MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} |
| 57 | + - name: Capture mod version |
| 58 | + if: steps.check_branch.outputs.is_release == 'true' |
| 59 | + run: echo "MOD_VERSION=$(./gradlew properties -q | grep '^version:' | awk '{print $2}')" >> $GITHUB_ENV |
| 60 | + - name: Comment on fixed issues |
| 61 | + if: steps.check_branch.outputs.is_release == 'true' |
| 62 | + uses: actions/github-script@v7 |
| 63 | + with: |
| 64 | + script: | |
| 65 | + const { execSync } = require('child_process'); |
| 66 | +
|
| 67 | + const branch = context.ref.replace('refs/heads/', ''); |
| 68 | + const { data: runs } = await github.rest.actions.listWorkflowRuns({ |
| 69 | + owner: context.repo.owner, |
| 70 | + repo: context.repo.repo, |
| 71 | + workflow_id: 'gradle.yml', |
| 72 | + branch, |
| 73 | + status: 'success', |
| 74 | + per_page: 1 |
| 75 | + }); |
| 76 | +
|
| 77 | + const logArgs = runs.workflow_runs.length > 0 |
| 78 | + ? `${runs.workflow_runs[0].head_sha}..${context.sha}` |
| 79 | + : `-1 ${context.sha}`; |
| 80 | + const log = execSync(`git log ${logArgs} --format=%s%n%b`, { encoding: 'utf8' }); |
| 81 | +
|
| 82 | + const issueNumbers = new Set(); |
| 83 | + const pattern = /(?:fix(?:es|ed)?|close[sd]?|resolve[sd]?)\s+#(\d+)/gi; |
| 84 | + let match; |
| 85 | + while ((match = pattern.exec(log)) !== null) { |
| 86 | + issueNumbers.add(parseInt(match[1])); |
| 87 | + } |
| 88 | +
|
| 89 | + if (issueNumbers.size === 0) { |
| 90 | + console.log('No fixed issues found in commits'); |
| 91 | + return; |
| 92 | + } |
| 93 | +
|
| 94 | + const version = process.env.MOD_VERSION; |
| 95 | + for (const issueNumber of issueNumbers) { |
| 96 | + try { |
| 97 | + await github.rest.issues.createComment({ |
| 98 | + owner: context.repo.owner, |
| 99 | + repo: context.repo.repo, |
| 100 | + issue_number: issueNumber, |
| 101 | + body: `The fix for this issue has been released in ModernFix ${version}` |
| 102 | + }); |
| 103 | + console.log(`Commented on issue #${issueNumber}`); |
| 104 | + } catch (e) { |
| 105 | + console.log(`Could not comment on #${issueNumber}: ${e.message}`); |
| 106 | + } |
| 107 | + } |
55 | 108 | - name: Upload Artifacts to GitHub |
56 | 109 | uses: actions/upload-artifact@v4 |
57 | 110 | with: |
|
0 commit comments