release.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - '*'
  6. workflow_dispatch:
  7. env:
  8. CARGO_TERM_COLOR: always
  9. jobs:
  10. release:
  11. name: Cross build for ${{ matrix.target }}
  12. runs-on: ${{ matrix.os }}
  13. strategy:
  14. matrix:
  15. include:
  16. - os: ubuntu-latest
  17. target: x86_64-unknown-linux-gnu
  18. exe: rathole
  19. - os: ubuntu-latest
  20. target: x86_64-unknown-linux-musl
  21. exe: rathole
  22. - os: ubuntu-latest
  23. target: aarch64-unknown-linux-musl
  24. exe: rathole
  25. - os: ubuntu-latest
  26. target: arm-unknown-linux-musleabi
  27. exe: rathole
  28. - os: ubuntu-latest
  29. target: arm-unknown-linux-musleabihf
  30. exe: rathole
  31. - os: ubuntu-latest
  32. target: armv7-unknown-linux-musleabihf
  33. exe: rathole
  34. - os: ubuntu-latest
  35. target: mips-unknown-linux-gnu
  36. exe: rathole
  37. - os: ubuntu-latest
  38. target: mips-unknown-linux-musl
  39. exe: rathole
  40. - os: ubuntu-latest
  41. target: mipsel-unknown-linux-gnu
  42. exe: rathole
  43. - os: ubuntu-latest
  44. target: mipsel-unknown-linux-musl
  45. exe: rathole
  46. - os: ubuntu-latest
  47. target: mips64-unknown-linux-gnuabi64
  48. exe: rathole
  49. - os: ubuntu-latest
  50. target: mips64el-unknown-linux-gnuabi64
  51. exe: rathole
  52. - os: macos-latest
  53. target: x86_64-apple-darwin
  54. exe: rathole
  55. - os: windows-latest
  56. target: x86_64-pc-windows-msvc
  57. exe: rathole.exe
  58. steps:
  59. - uses: actions/checkout@v2
  60. - uses: actions-rs/toolchain@v1
  61. with:
  62. profile: minimal
  63. toolchain: stable
  64. - name: Install cross
  65. run: cargo install --version 0.1.16 cross
  66. - name: Run tests
  67. run: cross test --release --target ${{ matrix.target }} --verbose
  68. - name: Build release
  69. run: cross build --release --target ${{ matrix.target }}
  70. - name: Install LLVM Strip
  71. if: matrix.os == 'ubuntu-latest'
  72. run: sudo apt-get install llvm
  73. - name: LLVM Strip
  74. if: matrix.os == 'ubuntu-latest'
  75. continue-on-error: true
  76. run: llvm-strip target/${{ matrix.target }}/release/${{ matrix.exe }}
  77. - name: MacOS Strip
  78. if: matrix.os == 'macos-latest'
  79. continue-on-error: true
  80. run: strip target/${{ matrix.target }}/release/${{ matrix.exe }}
  81. - name: Run UPX
  82. # Upx may not support some platforms. Ignore the errors
  83. continue-on-error: true
  84. # Disable upx for mips. See https://github.com/upx/upx/issues/387
  85. if: matrix.os == 'ubuntu-latest' && !contains(matrix.target, 'mips')
  86. uses: crazy-max/ghaction-upx@v1
  87. with:
  88. version: v3.96
  89. files: target/${{ matrix.target }}/release/${{ matrix.exe }}
  90. args: -q --best --lzma
  91. - uses: actions/upload-artifact@v2
  92. with:
  93. name: rathole-${{ matrix.target }}
  94. path: target/${{ matrix.target }}/release/${{ matrix.exe }}
  95. - name: Zip Release
  96. uses: TheDoctor0/zip-release@0.6.1
  97. with:
  98. type: zip
  99. filename: rathole-${{ matrix.target }}.zip
  100. directory: target/${{ matrix.target }}/release/
  101. path: ${{ matrix.exe }}
  102. - name: Publish
  103. uses: softprops/action-gh-release@v1
  104. if: startsWith(github.ref, 'refs/tags/')
  105. with:
  106. files: target/${{ matrix.target }}/release/rathole-${{ matrix.target }}.zip
  107. generate_release_notes: true
  108. draft: true
  109. docker:
  110. name: Publish to Docker Hub
  111. if: startsWith(github.ref, 'refs/tags/')
  112. runs-on: ubuntu-latest
  113. needs: release
  114. steps:
  115. - name: Set up Docker Buildx
  116. uses: docker/setup-buildx-action@v1
  117. - name: Login to DockerHub
  118. uses: docker/login-action@v1
  119. with:
  120. username: ${{ secrets.DOCKERHUB_USERNAME }}
  121. password: ${{ secrets.DOCKERHUB_TOKEN }}
  122. - name: Build and push
  123. id: docker_build
  124. uses: docker/build-push-action@v2
  125. with:
  126. push: true
  127. tags: rapiz1/rathole:latest, rapiz1/rathole:${{ github.ref_name }}
  128. publish-crate:
  129. name: Publish to crates.io
  130. if: startsWith(github.ref, 'refs/tags/')
  131. runs-on: ubuntu-latest
  132. needs: release
  133. steps:
  134. - uses: actions/checkout@v2
  135. - uses: actions-rs/toolchain@v1
  136. with:
  137. profile: minimal
  138. toolchain: stable
  139. - name: Publish
  140. env:
  141. CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}
  142. run: cargo publish