main.yml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. name: UFBT Build and Release
  2. permissions:
  3. contents: write
  4. on:
  5. push:
  6. branches:
  7. - main
  8. pull_request:
  9. branches:
  10. - main
  11. jobs:
  12. build:
  13. name: Build and Test
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Checkout Repository
  17. uses: actions/checkout@v3
  18. - name: Set up Python
  19. uses: actions/setup-python@v4
  20. with:
  21. python-version: '3.x'
  22. - name: Install UFBT
  23. run: |
  24. python3 -m pip install --upgrade pip
  25. pip install ufbt
  26. - name: Extract Version from Manifest
  27. id: extract_version
  28. run: |
  29. VERSION=$(grep '^version:' manifest.yml | awk '{print $2}')
  30. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  31. - name: Initialize UFBT Environment
  32. run: |
  33. ufbt update
  34. ufbt vscode_dist
  35. - name: Build FAP Applications
  36. run: ufbt faps
  37. - name: Rename and Move FAP File
  38. run: |
  39. mkdir -p build/fap
  40. mv /home/runner/.ufbt/build/metroflip.fap build/fap/metroflip-${{ env.VERSION }}.fap
  41. - name: Upload Build Artifacts
  42. if: github.event_name == 'pull_request'
  43. uses: actions/upload-artifact@v3
  44. with:
  45. name: metroflip-build
  46. path: build/fap/metroflip-${{ env.VERSION }}.fap
  47. release:
  48. name: Create Release
  49. needs: build
  50. if: github.event_name == 'push' && github.ref == 'refs/heads/main'
  51. runs-on: ubuntu-latest
  52. steps:
  53. - name: Checkout Repository
  54. uses: actions/checkout@v3
  55. - name: Extract Version from Manifest
  56. id: extract_version
  57. run: |
  58. VERSION=$(grep '^version:' manifest.yml | awk '{print $2}')
  59. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  60. - name: Create Release
  61. uses: actions/create-release@v1
  62. with:
  63. tag_name: v${{ env.VERSION }}
  64. release_name: Metroflip v${{ env.VERSION }}
  65. body: |
  66. **What's New:**
  67. $(cat CHANGELOG.md)
  68. draft: false
  69. prerelease: false
  70. env:
  71. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  72. - name: Upload FAP File to Release
  73. uses: actions/upload-release-asset@v1
  74. with:
  75. release_id: ${{ steps.create-release.outputs.id }}
  76. asset_path: build/fap/metroflip-${{ env.VERSION }}.fap
  77. asset_name: metroflip-${{ env.VERSION }}.fap
  78. asset_content_type: application/octet-stream