release.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. name: Release
  2. on:
  3. push:
  4. tags:
  5. - '*'
  6. env:
  7. CARGO_TERM_COLOR: always
  8. jobs:
  9. release:
  10. name: Cross build for ${{ matrix.target }}
  11. runs-on: ${{ matrix.os }}
  12. strategy:
  13. matrix:
  14. include:
  15. - os: ubuntu-latest
  16. target: x86_64-unknown-linux-gnu
  17. exe: rathole
  18. - os: ubuntu-latest
  19. target: x86_64-unknown-linux-musl
  20. exe: rathole
  21. - os: ubuntu-latest
  22. target: aarch64-unknown-linux-musl
  23. exe: rathole
  24. - os: ubuntu-latest
  25. target: arm-unknown-linux-musleabi
  26. exe: rathole
  27. - os: ubuntu-latest
  28. target: arm-unknown-linux-musleabihf
  29. exe: rathole
  30. - os: ubuntu-latest
  31. target: armv7-unknown-linux-musleabihf
  32. exe: rathole
  33. - os: ubuntu-latest
  34. target: mips-unknown-linux-musl
  35. exe: rathole
  36. - os: ubuntu-latest
  37. target: mipsel-unknown-linux-musl
  38. exe: rathole
  39. - os: ubuntu-latest
  40. target: mips64-unknown-linux-gnuabi64
  41. exe: rathole
  42. - os: ubuntu-latest
  43. target: mips64el-unknown-linux-gnuabi64
  44. exe: rathole
  45. - os: macos-latest
  46. target: x86_64-apple-darwin
  47. exe: rathole
  48. - os: windows-latest
  49. target: x86_64-pc-windows-msvc
  50. exe: rathole.exe
  51. steps:
  52. - uses: actions/checkout@v2
  53. - uses: actions-rs/toolchain@v1
  54. with:
  55. profile: minimal
  56. toolchain: stable
  57. - uses: Swatinem/rust-cache@v1
  58. with:
  59. key: ${{ matrix.target }}
  60. - name: Install cross
  61. run: cargo install --version 0.1.16 cross
  62. - name: Run tests
  63. run: cross test --release --target ${{ matrix.target }} --verbose
  64. - name: Build release
  65. run: cross build --release --target ${{ matrix.target }}
  66. - name: Strip
  67. if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
  68. continue-on-error: true
  69. run: strip target/${{ matrix.target }}/release/${{ matrix.exe }}
  70. - name: Run UPX
  71. # Upx may not support some platforms. Ignore the errors
  72. continue-on-error: true
  73. if: matrix.os == 'ubuntu-latest'
  74. uses: crazy-max/ghaction-upx@v1
  75. with:
  76. version: v3.96
  77. files: target/${{ matrix.target }}/release/${{ matrix.exe }}
  78. args: -q --best --lzma
  79. - uses: actions/upload-artifact@v2
  80. with:
  81. name: rathole-${{ matrix.target }}
  82. path: target/${{ matrix.target }}/release/${{ matrix.exe }}
  83. - name: Zip Release
  84. uses: TheDoctor0/zip-release@0.6.0
  85. with:
  86. type: zip
  87. filename: rathole-${{ matrix.target }}.zip
  88. directory: target/${{ matrix.target }}/release/
  89. path: ${{ matrix.exe }}
  90. - name: Publish
  91. uses: softprops/action-gh-release@v1
  92. if: startsWith(github.ref, 'refs/tags/')
  93. with:
  94. files: target/${{ matrix.target }}/release/rathole-${{ matrix.target }}.zip
  95. generate_release_notes: true
  96. docker:
  97. runs-on: ubuntu-latest
  98. steps:
  99. - name: Set up Docker Buildx
  100. uses: docker/setup-buildx-action@v1
  101. - name: Login to DockerHub
  102. uses: docker/login-action@v1
  103. with:
  104. username: ${{ secrets.DOCKERHUB_USERNAME }}
  105. password: ${{ secrets.DOCKERHUB_TOKEN }}
  106. - name: Build and push
  107. id: docker_build
  108. uses: docker/build-push-action@v2
  109. with:
  110. push: true
  111. tags: rapiz1/rathole:latest, rapiz1/rathole:${{ github.ref_name }}