publish.yml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. name: Publish Mah
  2. on:
  3. push:
  4. tags: [ 'v*' ]
  5. jobs:
  6. build:
  7. name: Publish to Maven Central
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Checkout
  11. uses: actions/checkout@v3
  12. - name: Set up JDK 11
  13. uses: actions/setup-java@v1
  14. with:
  15. java-version: 11
  16. - name: Grant Execute Permission for gradlew
  17. run: chmod +x gradlew
  18. - run: ./gradlew checkMavenCentralPublication --info --scan
  19. env:
  20. PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }}
  21. - name: Build with Gradle
  22. run: ./gradlew buildCiJar
  23. - name: Build SPI
  24. run: ./gradlew buildSpi
  25. - name: Publish to Maven Central
  26. run: ./gradlew mirai-api-http:publish --info --scan
  27. env:
  28. PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }}
  29. - name: Publish to SPI Maven Central
  30. run: ./gradlew mirai-api-http-spi:publish --info --scan
  31. env:
  32. PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }}
  33. - name: Get Tag
  34. id: tag
  35. run: |
  36. tag=$(echo ${{ github.ref }} | cut -dv -f2)
  37. echo "tag=$tag" >> $GITHUB_OUTPUT
  38. - name: Generate Line Temp File
  39. run: "cat CHANGELOG.md | grep -n '## \\\\' | cut -d: -f1 | head -n 2 >> line.tmp"
  40. - name: Generate Release Log
  41. run: "cat CHANGELOG.md | head -n $((`tail -n 1 line.tmp`-1)) | tail -n +`head -n 1 line.tmp` >> release.log"
  42. - name: Create Release
  43. id: create_release
  44. uses: softprops/action-gh-release@v1
  45. with:
  46. tag_name: ${{ github.ref }}
  47. name: mirai-api-http-${{ steps.tag.outputs.tag }}
  48. body_path: release.log
  49. draft: false
  50. prerelease: false
  51. files: |
  52. ./mirai-api-http/build/ci/mirai-api-http-${{ steps.tag.outputs.tag }}.mirai2.jar
  53. - name: Clone Mirai-Repo
  54. uses: actions/checkout@v3
  55. with:
  56. repository: project-mirai/mirai-repo-mirror
  57. token: ${{ secrets.MAMOEBOT_TOKEN }}
  58. path: ./mirai-repo-mirror
  59. - name: Modify package.json
  60. uses: ./.github/actions/modify-package-json
  61. with:
  62. defaultChannel: stable-v2
  63. version: ${{ steps.tag.outputs.tag }}
  64. srcPath: mirai-repo-mirror/net/mamoe/mirai-api-http/package.json
  65. destPath: .github/package.json
  66. - name: Move package.json
  67. run: |
  68. cp .github/package.json mirai-repo-mirror/net/mamoe/mirai-api-http/package.json
  69. - name: Create PR for Mirai-Repo
  70. uses: peter-evans/create-pull-request@v4
  71. with:
  72. token: ${{ secrets.MAMOEBOT_TOKEN }}
  73. commit-message: 'update: mirai-api-http ${{ steps.tag.outputs.tag }}'
  74. title: 'update: mirai-api-http ${{ steps.tag.outputs.tag }}'
  75. branch: create-pull-request/mah-update-version
  76. delete-branch: true