build.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. name: Build + Publish
  2. on:
  3. push:
  4. branches:
  5. - vega
  6. jobs:
  7. build:
  8. name: Build
  9. runs-on: ubuntu-latest
  10. permissions:
  11. packages: write
  12. steps:
  13. - uses: actions/checkout@v4
  14. - name: Setup Node.js environment
  15. uses: actions/setup-node@v4
  16. with:
  17. node-version: 20.x
  18. - name: Enable pnpm
  19. run: |
  20. corepack enable
  21. corepack prepare pnpm@latest --activate
  22. - name: Set Build Variables
  23. run: |
  24. echo "REL_VERSION=3.0.0-alpha.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
  25. - name: Disable DEV Flag + Set Version
  26. working-directory: server
  27. run: |
  28. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  29. brew install jq
  30. mv package.json pkg-temp.json
  31. jq --arg vs "$REL_VERSION_STRICT" -r '. + {dev:false, version:$vs}' pkg-temp.json > package.json
  32. rm pkg-temp.json
  33. cat package.json
  34. - name: Fetch Latest Locales
  35. uses: localazy/download@v1
  36. with:
  37. read_key: ${{ secrets.LOCALAZY_KEY_READ }}
  38. - name: Build Assets
  39. working-directory: ux
  40. run: |
  41. pnpm install --frozen-lockfile --shamefully-hoist
  42. pnpm build
  43. - name: Build Blocks
  44. working-directory: blocks
  45. run: |
  46. pnpm install --frozen-lockfile
  47. pnpm build
  48. - name: Login to GitHub Container Registry
  49. uses: docker/login-action@v2
  50. with:
  51. registry: ghcr.io
  52. username: ${{ github.repository_owner }}
  53. password: ${{ secrets.GITHUB_TOKEN }}
  54. - name: Set up QEMU
  55. uses: docker/setup-qemu-action@v2
  56. - name: Set up Docker Buildx
  57. uses: docker/setup-buildx-action@v2
  58. - name: Build and push Docker images
  59. uses: docker/build-push-action@v4
  60. with:
  61. context: .
  62. file: dev/build/Dockerfile
  63. provenance: true
  64. push: true
  65. # cache-from: type=gha
  66. # cache-to: type=gha,mode=max
  67. platforms: linux/amd64,linux/arm64
  68. tags: |
  69. ghcr.io/requarks/wiki:3.0.0-alpha
  70. ghcr.io/requarks/wiki:${{ env.REL_VERSION }}
  71. - name: Prepare build archive
  72. run: |
  73. mkdir -p _dist
  74. cp -R assets _dist/assets
  75. cp -R server _dist/server
  76. cp LICENSE _dist/LICENSE
  77. cp config.sample.yml _dist/config.sample.yml
  78. cd _dist/server
  79. pnpm install --prod --frozen-lockfile
  80. cd -
  81. find ./_dist/ -printf "%P\n" | tar -czf wiki-js.tar.gz --no-recursion -C ./_dist/ -T -
  82. - name: Upload Build Artifact
  83. uses: actions/upload-artifact@v3
  84. with:
  85. name: build
  86. path: wiki-js.tar.gz
  87. windows:
  88. name: Windows Build
  89. runs-on: windows-latest
  90. needs: [build]
  91. steps:
  92. - name: Setup Node.js environment
  93. uses: actions/setup-node@v3
  94. with:
  95. node-version: 20.x
  96. - name: Enable pnpm
  97. run: |
  98. corepack enable
  99. corepack prepare pnpm@latest --activate
  100. - name: Download Build Artifact
  101. uses: actions/download-artifact@v3
  102. with:
  103. name: build
  104. path: build
  105. - name: Extract Build
  106. run: |
  107. mkdir -p win
  108. tar -xzf $env:GITHUB_WORKSPACE\build\wiki-js.tar.gz -C $env:GITHUB_WORKSPACE\win --exclude=server/node_modules
  109. - name: Install Dependencies
  110. run: pnpm install --prod --frozen-lockfile
  111. working-directory: win\server
  112. - name: Create Bundle
  113. shell: pwsh
  114. run: Compress-Archive -Path $env:GITHUB_WORKSPACE\win\* -DestinationPath wiki-js-windows.zip
  115. - name: Upload Build Artifact
  116. uses: actions/upload-artifact@v3
  117. with:
  118. name: build-win
  119. path: wiki-js-windows.zip