release.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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' || matrix.os == 'macos-latest'
  75. continue-on-error: true
  76. run: llvm-strip target/${{ matrix.target }}/release/${{ matrix.exe }}
  77. - name: Run UPX
  78. # Upx may not support some platforms. Ignore the errors
  79. continue-on-error: true
  80. # Disable upx for mips. See https://github.com/upx/upx/issues/387
  81. if: matrix.os == 'ubuntu-latest' && !contains(matrix.target, 'mips')
  82. uses: crazy-max/ghaction-upx@v1
  83. with:
  84. version: v3.96
  85. files: target/${{ matrix.target }}/release/${{ matrix.exe }}
  86. args: -q --best --lzma
  87. - uses: actions/upload-artifact@v2
  88. with:
  89. name: rathole-${{ matrix.target }}
  90. path: target/${{ matrix.target }}/release/${{ matrix.exe }}
  91. - name: Zip Release
  92. uses: TheDoctor0/zip-release@0.6.1
  93. with:
  94. type: zip
  95. filename: rathole-${{ matrix.target }}.zip
  96. directory: target/${{ matrix.target }}/release/
  97. path: ${{ matrix.exe }}
  98. - name: Publish
  99. uses: softprops/action-gh-release@v1
  100. if: startsWith(github.ref, 'refs/tags/')
  101. with:
  102. files: target/${{ matrix.target }}/release/rathole-${{ matrix.target }}.zip
  103. generate_release_notes: true
  104. draft: true
  105. docker:
  106. name: Publish to Docker Hub
  107. if: startsWith(github.ref, 'refs/tags/')
  108. runs-on: ubuntu-latest
  109. needs: release
  110. steps:
  111. - name: Set up Docker Buildx
  112. uses: docker/setup-buildx-action@v1
  113. - name: Login to DockerHub
  114. uses: docker/login-action@v1
  115. with:
  116. username: ${{ secrets.DOCKERHUB_USERNAME }}
  117. password: ${{ secrets.DOCKERHUB_TOKEN }}
  118. - name: Build and push
  119. id: docker_build
  120. uses: docker/build-push-action@v2
  121. with:
  122. push: true
  123. tags: rapiz1/rathole:latest, rapiz1/rathole:${{ github.ref_name }}
  124. publish-crate:
  125. name: Publish to crates.io
  126. if: startsWith(github.ref, 'refs/tags/')
  127. runs-on: ubuntu-latest
  128. needs: release
  129. steps:
  130. - uses: actions/checkout@v2
  131. - uses: actions-rs/toolchain@v1
  132. with:
  133. profile: minimal
  134. toolchain: stable
  135. - name: Publish
  136. env:
  137. CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}
  138. run: cargo publish