build-artifacts.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. name: build-artifacts
  2. on:
  3. push:
  4. branches:
  5. # Run on pushing branches like `release/1.0.0`
  6. - "release/*.*.*"
  7. jobs:
  8. build-artifacts:
  9. runs-on: ${{ matrix.os }}
  10. strategy:
  11. matrix:
  12. os: [ubuntu-latest, macos-latest]
  13. goarch: [amd64, arm64]
  14. include:
  15. - os: windows-latest
  16. goos: windows
  17. goarch: amd64
  18. cgo_env: CC=x86_64-w64-mingw32-gcc
  19. env:
  20. GOOS: ${{ matrix.goos }}
  21. GOARCH: ${{ matrix.goarch }}
  22. CGO_ENABLED: 1
  23. steps:
  24. - name: Checkout repository
  25. uses: actions/checkout@v2
  26. - name: Clone Memos
  27. run: git clone https://github.com/usememos/memos.git
  28. - name: Setup Node.js
  29. uses: actions/setup-node@v2
  30. with:
  31. node-version: "18"
  32. - name: Build frontend (Windows)
  33. if: matrix.os == 'windows-latest'
  34. shell: pwsh
  35. run: |
  36. cd memos/web
  37. npm install -g pnpm
  38. pnpm i --frozen-lockfile
  39. pnpm build
  40. Remove-Item -Path ../server/dist -Recurse -Force
  41. mv dist ../server/
  42. - name: Build frontend (non-Windows)
  43. if: matrix.os != 'windows-latest'
  44. run: |
  45. cd memos/web
  46. npm install -g pnpm
  47. pnpm i --frozen-lockfile
  48. pnpm build
  49. rm -rf ../server/dist
  50. mv dist ../server/
  51. - name: Setup Go
  52. uses: actions/setup-go@v3
  53. with:
  54. go-version: 1.19
  55. - name: Install mingw-w64 (Windows)
  56. if: matrix.os == 'windows-latest'
  57. run: |
  58. choco install mingw
  59. echo ${{ matrix.cgo_env }} >> $GITHUB_ENV
  60. - name: Install gcc-aarch64-linux-gnu (Ubuntu ARM64)
  61. if: matrix.os == 'ubuntu-latest' && matrix.goarch == 'arm64'
  62. run: |
  63. sudo apt-get update
  64. sudo apt-get install -y gcc-aarch64-linux-gnu
  65. echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
  66. - name: Build backend
  67. run: |
  68. cd memos
  69. go build -o memos-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }} ./main.go
  70. - name: Upload artifacts
  71. uses: actions/upload-artifact@v2
  72. with:
  73. name: memos-binary-${{ matrix.os }}-${{ matrix.goarch }}
  74. path: memos/memos-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}