publish.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 mirai-api-http:checkMavenCentralPublication --info --scan
  19. env:
  20. PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }}
  21. - run: ./gradlew mirai-api-http-spi:checkMavenCentralPublication --info --scan
  22. env:
  23. PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }}
  24. - name: Build with Gradle
  25. run: ./gradlew buildCiJar
  26. - name: Build SPI
  27. run: ./gradlew buildSpi
  28. - name: Publish to Maven Central
  29. run: ./gradlew mirai-api-http:publish --info --scan
  30. env:
  31. PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }}
  32. - name: Publish SPI to Maven Central
  33. run: ./gradlew mirai-api-http-spi:publish --info --scan
  34. env:
  35. PUBLICATION_CREDENTIALS: ${{ secrets.PUBLICATION_CREDENTIALS }}
  36. - name: Get Tag
  37. id: tag
  38. run: |
  39. tag=$(echo ${{ github.ref }} | cut -dv -f2)
  40. echo "tag=$tag" >> $GITHUB_OUTPUT
  41. - name: Generate Line Temp File
  42. run: "cat CHANGELOG.md | grep -n '## \\\\' | cut -d: -f1 | head -n 2 >> line.tmp"
  43. - name: Generate Release Log
  44. run: "cat CHANGELOG.md | head -n $((`tail -n 1 line.tmp`-1)) | tail -n +`head -n 1 line.tmp` >> release.log"
  45. - name: Create Release
  46. id: create_release
  47. uses: softprops/action-gh-release@v1
  48. with:
  49. tag_name: ${{ github.ref }}
  50. name: mirai-api-http-${{ steps.tag.outputs.tag }}
  51. body_path: release.log
  52. draft: false
  53. prerelease: false
  54. files: |
  55. ./mirai-api-http/build/ci/mirai-api-http-${{ steps.tag.outputs.tag }}.mirai2.jar
  56. - name: Clone Mirai-Repo
  57. uses: actions/checkout@v3
  58. with:
  59. repository: project-mirai/mirai-repo-mirror
  60. ref: master
  61. token: ${{ secrets.MAMOEBOT_TOKEN }}
  62. path: ./mirai-repo-mirror
  63. - name: Modify package.json
  64. uses: ./.github/actions/modify-package-json
  65. with:
  66. defaultChannel: stable-v2
  67. version: ${{ steps.tag.outputs.tag }}
  68. srcPath: mirai-repo-mirror/net/mamoe/mirai-api-http/package.json
  69. destPath: .github/package.json
  70. - name: Move package.json
  71. run: |
  72. cp .github/package.json mirai-repo-mirror/net/mamoe/mirai-api-http/package.json
  73. - name: Create PR for Mirai-Repo
  74. uses: peter-evans/create-pull-request@v4
  75. with:
  76. token: ${{ secrets.MAMOEBOT_TOKEN }}
  77. commit-message: 'update: mirai-api-http ${{ steps.tag.outputs.tag }}'
  78. title: 'update: mirai-api-http ${{ steps.tag.outputs.tag }}'
  79. branch: create-pull-request/mah-update-version
  80. delete-branch: true
  81. path: ./mirai-repo-mirror
  82. base: master