release.yml 4.2 KB

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