release.yml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: Release
  2. on: [create]
  3. jobs:
  4. create_release:
  5. if: startsWith(github.ref, 'refs/tags/v')
  6. runs-on: ubuntu-latest
  7. outputs:
  8. upload_url: ${{ steps.create_release.outputs.upload_url }}
  9. steps:
  10. - name: Create release
  11. id: create_release
  12. uses: actions/create-release@v1
  13. env:
  14. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  15. with:
  16. tag_name: ${{ github.ref }}
  17. release_name: MCRPC ${{ github.ref }}
  18. draft: true
  19. prerelease: false
  20. build_and_upload_release_asset:
  21. name: Upload Release Asset
  22. needs: create_release
  23. runs-on: ${{ matrix.config.os }}
  24. strategy:
  25. fail-fast: false
  26. matrix:
  27. config:
  28. - { os: ubuntu-latest, asset: mcrpc-linux, path: mcrpc.bin }
  29. - { os: windows-latest, asset: mcrpc-windows.exe, path: mcrpc.exe }
  30. - { os: macos-latest, asset: mcrpc-macos, path: mcrpc.bin }
  31. steps:
  32. - name: Checkout code
  33. uses: actions/checkout@v2
  34. - name: Install python
  35. uses: actions/setup-python@v4
  36. with:
  37. python-version: '3.7'
  38. check-latest: true
  39. cache: 'pip'
  40. - name: Setup Poetry
  41. uses: pronovic/setup-poetry@v1
  42. with:
  43. version: "1.2.0"
  44. cache-venv: "true"
  45. cache-poetry: "true"
  46. - name: Set short version
  47. shell: bash
  48. run: |
  49. echo "VERSION=$(poetry version | sed -e 's/mcrpc //')" >> $GITHUB_ENV
  50. - name: Install python dependencies
  51. run: |
  52. poetry install --with dev
  53. - name: Build with poetry
  54. if: runner.os == 'Linux'
  55. run: |
  56. poetry build
  57. - name: Build with nuitka
  58. run: |
  59. poetry run python -m nuitka --assume-yes-for-downloads --follow-imports --enable-plugin=anti-bloat --onefile mcrpc.py
  60. - name: Upload release asset
  61. uses: actions/upload-release-asset@v1
  62. env:
  63. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  64. with:
  65. upload_url: ${{ needs.create_release.outputs.upload_url }}
  66. asset_name: ${{ matrix.config.asset }}
  67. asset_path: ${{ matrix.config.path }}
  68. asset_content_type: application/octet_stream
  69. - name: Upload release asset (Poetry tar.gz)
  70. if: runner.os == 'Linux'
  71. uses: actions/upload-release-asset@v1
  72. env:
  73. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  74. with:
  75. upload_url: ${{ needs.create_release.outputs.upload_url }}
  76. asset_name: mcrpc-${{ env.VERSION }}.tar.gz
  77. asset_path: dist/mcrpc-${{ env.VERSION }}.tar.gz
  78. asset_content_type: application/gzip
  79. - name: Upload release asset (Poetry whl)
  80. if: runner.os == 'Linux'
  81. uses: actions/upload-release-asset@v1
  82. env:
  83. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  84. with:
  85. upload_url: ${{ needs.create_release.outputs.upload_url }}
  86. asset_name: mcrpc-${{ env.VERSION }}-py3-none-any.whl
  87. asset_path: dist/mcrpc-${{ env.VERSION }}-py3-none-any.whl
  88. asset_content_type: application/zip