static.yaml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ---
  2. name: Build binary releases
  3. on:
  4. pull_request:
  5. branches:
  6. - main
  7. push:
  8. branches:
  9. - main
  10. tags:
  11. - v*.*.*
  12. workflow_dispatch:
  13. inputs: {}
  14. jobs:
  15. release:
  16. if: github.ref_type == 'tag'
  17. name: Create GitHub Release
  18. runs-on: ubuntu-latest
  19. steps:
  20. - name: Create release
  21. uses: ncipollo/release-action@v1
  22. with:
  23. generateReleaseNotes: true
  24. allowUpdates: true
  25. omitBodyDuringUpdate: true
  26. omitNameDuringUpdate: true
  27. build-linux:
  28. name: Build Linux x86_64 binary
  29. runs-on: ubuntu-latest
  30. steps:
  31. -
  32. uses: actions/checkout@v4
  33. -
  34. name: Set up Docker Buildx
  35. uses: docker/setup-buildx-action@v3
  36. with:
  37. version: latest
  38. -
  39. name: Login to DockerHub
  40. if: ${{toJson(startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request'))}}
  41. uses: docker/login-action@v3
  42. with:
  43. username: ${{secrets.REGISTRY_USERNAME}}
  44. password: ${{secrets.REGISTRY_PASSWORD}}
  45. -
  46. name: Build
  47. id: build
  48. uses: docker/bake-action@v4
  49. with:
  50. pull: true
  51. load: true
  52. push: ${{toJson(startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request'))}}
  53. targets: static-builder
  54. set: |
  55. *.cache-from=type=gha,scope=${{github.ref}}-static-builder
  56. *.cache-from=type=gha,scope=refs/heads/main-static-builder
  57. *.cache-to=type=gha,scope=${{github.ref}}-static-builder
  58. env:
  59. LATEST: '1' # TODO: unset this variable when releasing the first stable version
  60. SHA: ${{github.sha}}
  61. VERSION: ${{github.ref_type == 'tag' && github.ref_name || github.sha}}
  62. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  63. -
  64. name: Copy binary
  65. run: docker cp "$(docker create --name static-builder dunglas/frankenphp:static-builder):/go/src/app/dist/frankenphp-linux-x86_64" frankenphp-linux-x86_64 ; docker rm static-builder
  66. -
  67. name: Upload asset
  68. if: github.ref_type == 'tag'
  69. uses: ncipollo/release-action@v1
  70. with:
  71. generateReleaseNotes: true
  72. allowUpdates: true
  73. omitBodyDuringUpdate: true
  74. omitNameDuringUpdate: true
  75. artifacts: frankenphp-linux-x86_64
  76. -
  77. name: Upload artifact
  78. if: github.ref_type == 'branch'
  79. uses: actions/upload-artifact@v3
  80. with:
  81. path: frankenphp-linux-x86_64
  82. build-mac:
  83. name: Build macOS x86_64 binaries
  84. runs-on: macos-latest
  85. env:
  86. HOMEBREW_NO_AUTO_UPDATE: 1
  87. steps:
  88. -
  89. uses: actions/checkout@v4
  90. -
  91. uses: actions/setup-go@v4
  92. with:
  93. go-version: '1.21'
  94. cache-dependency-path: |
  95. go.sum
  96. caddy/go.sum
  97. -
  98. name: Set FRANKENPHP_VERSION
  99. run: |
  100. if [ "$GITHUB_REF_TYPE" == "tag" ]; then export FRANKENPHP_VERSION=${GITHUB_REF_NAME:1}; else export FRANKENPHP_VERSION=$GITHUB_SHA; fi
  101. echo "FRANKENPHP_VERSION=$FRANKENPHP_VERSION" >> "$GITHUB_ENV"
  102. -
  103. name: Build FrankenPHP
  104. run: ./build-static.sh
  105. env:
  106. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  107. -
  108. name: Upload asset
  109. if: github.ref_type == 'tag'
  110. uses: ncipollo/release-action@v1
  111. with:
  112. generateReleaseNotes: true
  113. allowUpdates: true
  114. omitBodyDuringUpdate: true
  115. omitNameDuringUpdate: true
  116. artifacts: dist/frankenphp-mac-x86_64
  117. -
  118. name: Upload binary
  119. uses: actions/upload-artifact@v3
  120. with:
  121. path: dist/frankenphp-mac-x86_64