dist.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. name: dist
  2. on:
  3. push:
  4. branches:
  5. - master
  6. tags:
  7. - '*'
  8. permissions:
  9. contents: write
  10. concurrency:
  11. group: crown-package-${{ github.ref }}
  12. cancel-in-progress: false
  13. jobs:
  14. detect:
  15. runs-on: ubuntu-22.04
  16. outputs:
  17. is_tag: ${{ steps.detect.outputs.is_tag }}
  18. version: ${{ steps.detect.outputs.version }}
  19. branch: ${{ steps.detect.outputs.branch }}
  20. steps:
  21. - name: prepare
  22. uses: actions/checkout@v4
  23. with:
  24. fetch-depth: 0
  25. ref: ${{ github.ref }}
  26. - name: detect
  27. id: detect
  28. run: |
  29. set -euo pipefail
  30. if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
  31. echo "is_tag=true" >> $GITHUB_OUTPUT
  32. echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
  33. echo "branch=" >> $GITHUB_OUTPUT
  34. else
  35. echo "is_tag=false" >> $GITHUB_OUTPUT
  36. if [ -n "${GITHUB_HEAD_REF:-}" ]; then
  37. BRANCH="${GITHUB_HEAD_REF}"
  38. else
  39. if [[ "${GITHUB_REF}" == refs/heads/* ]]; then
  40. BRANCH="${GITHUB_REF#refs/heads/}"
  41. else
  42. BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
  43. if [ -z "${BRANCH:-}" ] || [ "${BRANCH}" = "HEAD" ]; then
  44. BRANCH="$(git name-rev --name-only HEAD 2>/dev/null || true)"
  45. fi
  46. BRANCH="${BRANCH#remotes/origin/}"
  47. fi
  48. fi
  49. echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
  50. if [[ "${BRANCH}" == "master" ]]; then
  51. echo "version=master" >> $GITHUB_OUTPUT
  52. else
  53. echo "version=${BRANCH}" >> $GITHUB_OUTPUT
  54. fi
  55. fi
  56. android-arm:
  57. needs: detect
  58. runs-on: ubuntu-22.04
  59. env:
  60. IS_TAG: ${{ needs.detect.outputs.is_tag }}
  61. VERSION: ${{ needs.detect.outputs.version }}
  62. BRANCH: ${{ needs.detect.outputs.branch }}
  63. steps:
  64. - name: prepare
  65. uses: actions/checkout@v4
  66. with:
  67. fetch-depth: 0
  68. ref: ${{ github.ref }}
  69. - name: detect
  70. run: |
  71. set -euo pipefail
  72. echo "IS_TAG=${IS_TAG}" >> $GITHUB_ENV
  73. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  74. echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
  75. - name: install-deps
  76. shell: bash
  77. run: |
  78. set -euo pipefail
  79. sudo apt-get update
  80. sudo apt-get install libc6-dev-i386
  81. ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
  82. SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
  83. echo "y" | $SDKMANAGER "ndk;23.2.8568313"
  84. - name: package
  85. shell: bash
  86. run: |
  87. set -euo pipefail
  88. export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/23.2.8568313
  89. export ANDROID_NDK_ABI=23
  90. if [ "$IS_TAG" = "true" ]; then
  91. ./scripts/dist/package.sh android arm --noconfirm
  92. else
  93. ./scripts/dist/package.sh android arm --branch "${BRANCH}" --noconfirm
  94. fi
  95. - name: upload-dist
  96. uses: actions/upload-artifact@v4
  97. with:
  98. name: dist-android-arm
  99. path: dist-android-arm.tar.gz
  100. retention-days: 1
  101. android-arm64:
  102. needs: detect
  103. runs-on: ubuntu-22.04
  104. env:
  105. IS_TAG: ${{ needs.detect.outputs.is_tag }}
  106. VERSION: ${{ needs.detect.outputs.version }}
  107. BRANCH: ${{ needs.detect.outputs.branch }}
  108. steps:
  109. - name: prepare
  110. uses: actions/checkout@v4
  111. with:
  112. fetch-depth: 0
  113. ref: ${{ github.ref }}
  114. - name: detect
  115. run: |
  116. set -euo pipefail
  117. echo "IS_TAG=${IS_TAG}" >> $GITHUB_ENV
  118. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  119. echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
  120. - name: install-deps
  121. shell: bash
  122. run: |
  123. set -euo pipefail
  124. sudo apt-get update
  125. sudo apt-get install libc6-dev-i386
  126. ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
  127. SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
  128. echo "y" | $SDKMANAGER "ndk;23.2.8568313"
  129. - name: package
  130. shell: bash
  131. run: |
  132. set -euo pipefail
  133. export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/23.2.8568313
  134. export ANDROID_NDK_ABI=23
  135. if [ "$IS_TAG" = "true" ]; then
  136. ./scripts/dist/package.sh android arm64 --noconfirm
  137. else
  138. ./scripts/dist/package.sh android arm64 --branch "${BRANCH}" --noconfirm
  139. fi
  140. - name: upload-dist
  141. uses: actions/upload-artifact@v4
  142. with:
  143. name: dist-android-arm64
  144. path: dist-android-arm64.tar.gz
  145. retention-days: 1
  146. html5-wasm:
  147. needs: detect
  148. runs-on: ubuntu-22.04
  149. env:
  150. IS_TAG: ${{ needs.detect.outputs.is_tag }}
  151. VERSION: ${{ needs.detect.outputs.version }}
  152. BRANCH: ${{ needs.detect.outputs.branch }}
  153. steps:
  154. - name: prepare
  155. uses: actions/checkout@v4
  156. with:
  157. fetch-depth: 0
  158. ref: ${{ github.ref }}
  159. - name: detect
  160. run: |
  161. set -euo pipefail
  162. echo "IS_TAG=${IS_TAG}" >> $GITHUB_ENV
  163. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  164. echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
  165. - name: install-deps
  166. shell: bash
  167. run: |
  168. set -euo pipefail
  169. git clone https://github.com/emscripten-core/emsdk.git "${GITHUB_WORKSPACE}/emsdk"
  170. pushd "${GITHUB_WORKSPACE}/emsdk"
  171. ./emsdk install latest
  172. ./emsdk activate latest
  173. popd
  174. - name: package
  175. shell: bash
  176. run: |
  177. set -euo pipefail
  178. export EMSCRIPTEN=$GITHUB_WORKSPACE/emsdk/upstream/emscripten
  179. if [ "$IS_TAG" = "true" ]; then
  180. ./scripts/dist/package.sh html5 wasm --noconfirm
  181. else
  182. ./scripts/dist/package.sh html5 wasm --branch "${BRANCH}" --noconfirm
  183. fi
  184. - name: upload-dist
  185. uses: actions/upload-artifact@v4
  186. with:
  187. name: dist-html5-wasm
  188. path: dist-html5-wasm.tar.gz
  189. retention-days: 1
  190. linux-x64:
  191. needs: detect
  192. runs-on: ubuntu-22.04
  193. env:
  194. IS_TAG: ${{ needs.detect.outputs.is_tag }}
  195. VERSION: ${{ needs.detect.outputs.version }}
  196. BRANCH: ${{ needs.detect.outputs.branch }}
  197. steps:
  198. - name: prepare
  199. uses: actions/checkout@v4
  200. with:
  201. fetch-depth: 0
  202. ref: ${{ github.ref }}
  203. - name: detect
  204. run: |
  205. set -euo pipefail
  206. echo "IS_TAG=${IS_TAG}" >> $GITHUB_ENV
  207. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  208. echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
  209. - name: install-deps
  210. shell: bash
  211. run: |
  212. set -euo pipefail
  213. sudo apt-get update
  214. sudo apt-get install -y mesa-common-dev libgl1-mesa-dev libpulse-dev libxrandr-dev libc6-dev-i386
  215. sudo apt-get install -y libgtk-3-dev
  216. sudo add-apt-repository ppa:vala-team -y
  217. sudo apt-get update
  218. sudo apt-get install -y valac libgee-0.8-dev
  219. sudo apt-get install -y libxml2-utils
  220. - name: package
  221. shell: bash
  222. run: |
  223. set -euo pipefail
  224. if [ "$IS_TAG" = "true" ]; then
  225. ./scripts/dist/package.sh linux x64 --noconfirm
  226. else
  227. ./scripts/dist/package.sh linux x64 --branch "${BRANCH}" --noconfirm
  228. fi
  229. - name: upload-dist
  230. uses: actions/upload-artifact@v4
  231. with:
  232. name: dist-linux-x64
  233. path: dist-linux-x64.tar.gz
  234. retention-days: 1
  235. windows-x64:
  236. needs: detect
  237. runs-on: windows-latest
  238. env:
  239. IS_TAG: ${{ needs.detect.outputs.is_tag }}
  240. VERSION: ${{ needs.detect.outputs.version }}
  241. BRANCH: ${{ needs.detect.outputs.branch }}
  242. steps:
  243. - name: setup-msys2
  244. uses: msys2/setup-msys2@v2
  245. with:
  246. msystem: MINGW64
  247. update: false
  248. - name: prepare
  249. uses: actions/checkout@v4
  250. with:
  251. fetch-depth: 0
  252. ref: ${{ github.ref }}
  253. - name: detect
  254. shell: msys2 {0}
  255. run: |
  256. set -euo pipefail
  257. echo "IS_TAG=${IS_TAG}" >> $GITHUB_ENV
  258. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  259. echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
  260. - name: install-deps
  261. shell: msys2 {0}
  262. run: |
  263. set -euo pipefail
  264. pacman --noconfirm -S make mingw-w64-x86_64-gcc mingw-w64-x86_64-pkgconf mingw-w64-x86_64-gtk3 mingw-w64-x86_64-vala mingw-w64-x86_64-libgee git
  265. - name: package
  266. shell: msys2 {0}
  267. run: |
  268. set -euo pipefail
  269. if [ "$IS_TAG" = "true" ]; then
  270. ./scripts/dist/package.sh windows x64 --noconfirm
  271. else
  272. ./scripts/dist/package.sh windows x64 --branch "${BRANCH}" --noconfirm
  273. fi
  274. - name: upload-dist
  275. uses: actions/upload-artifact@v4
  276. with:
  277. name: dist-windows-x64
  278. path: dist-windows-x64.tar.gz
  279. retention-days: 1
  280. windows-x32:
  281. needs: detect
  282. runs-on: windows-latest
  283. env:
  284. IS_TAG: ${{ needs.detect.outputs.is_tag }}
  285. VERSION: ${{ needs.detect.outputs.version }}
  286. BRANCH: ${{ needs.detect.outputs.branch }}
  287. steps:
  288. - name: setup-msys2
  289. uses: msys2/setup-msys2@v2
  290. with:
  291. msystem: MINGW32
  292. update: false
  293. - name: prepare
  294. uses: actions/checkout@v4
  295. with:
  296. fetch-depth: 0
  297. ref: ${{ github.ref }}
  298. - name: detect
  299. shell: msys2 {0}
  300. run: |
  301. set -euo pipefail
  302. echo "IS_TAG=${IS_TAG}" >> $GITHUB_ENV
  303. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  304. echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
  305. - name: install-deps
  306. shell: msys2 {0}
  307. run: |
  308. set -euo pipefail
  309. pacman --noconfirm -S make mingw-w64-i686-gcc mingw-w64-i686-pkgconf git
  310. - name: package
  311. shell: msys2 {0}
  312. run: |
  313. set -euo pipefail
  314. if [ "$IS_TAG" = "true" ]; then
  315. ./scripts/dist/package.sh windows x32 --noconfirm
  316. else
  317. ./scripts/dist/package.sh windows x32 --branch "${BRANCH}" --noconfirm
  318. fi
  319. - name: upload-dist
  320. uses: actions/upload-artifact@v4
  321. with:
  322. name: dist-windows-x32
  323. path: dist-windows-x32.tar.gz
  324. retention-days: 1
  325. finalize:
  326. needs:
  327. - android-arm
  328. - android-arm64
  329. - html5-wasm
  330. - linux-x64
  331. - windows-x64
  332. - windows-x32
  333. - detect
  334. runs-on: ubuntu-22.04
  335. env:
  336. IS_TAG: ${{ needs.detect.outputs.is_tag }}
  337. VERSION: ${{ needs.detect.outputs.version }}
  338. BRANCH: ${{ needs.detect.outputs.branch }}
  339. steps:
  340. - name: prepare
  341. uses: actions/checkout@v4
  342. with:
  343. fetch-depth: 0
  344. ref: ${{ github.ref }}
  345. - name: detect
  346. run: |
  347. set -euo pipefail
  348. echo "IS_TAG=${IS_TAG}" >> $GITHUB_ENV
  349. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  350. echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
  351. - name: download-artifacts
  352. uses: actions/download-artifact@v4
  353. with:
  354. path: ./artifacts_dist
  355. - name: merge
  356. run: |
  357. set -euo pipefail
  358. # Uncompress.
  359. mkdir -p dist
  360. for ad in ./artifacts_dist/*; do
  361. if [ -d "$ad" ]; then
  362. for f in "$ad"/*.tar.gz; do
  363. if [ -f "$f" ]; then
  364. mkdir -p "$ad/extracted"
  365. tar -xzf "$f" -C "$ad/extracted"
  366. fi
  367. done
  368. cp -a "$ad/extracted/dist/"* ./dist/
  369. fi
  370. done
  371. # Merge.
  372. find ./artifacts_dist -maxdepth 3 -type d -name 'crown-*' -exec cp -a {} ./dist/ \;
  373. - name: detect-version
  374. run: |
  375. set -euo pipefail
  376. . ./scripts/dist/version.sh
  377. CROWN_VER=$(crown_version)
  378. if [ "${IS_TAG}" = "true" ]; then
  379. VERSIONNAME=crown-${CROWN_VER}
  380. else
  381. SUFFIX="$(git rev-parse --short HEAD)"
  382. VERSIONNAME=crown-${CROWN_VER}-${BRANCH}-${SUFFIX}
  383. fi
  384. DIST_DIR="dist/${VERSIONNAME}"
  385. echo "DIST_DIR=$DIST_DIR" >> $GITHUB_ENV
  386. echo "VERSIONNAME=$VERSIONNAME" >> $GITHUB_ENV
  387. - name: finalize
  388. run: |
  389. set -euo pipefail
  390. "$GITHUB_WORKSPACE/scripts/dist/finalize.sh" "${DIST_DIR}"
  391. - name: sums
  392. run: |
  393. set -euo pipefail
  394. "$GITHUB_WORKSPACE/scripts/dist/sums.sh" "${DIST_DIR}"
  395. - name: unstable
  396. if: env.IS_TAG == 'false'
  397. uses: Jumbo810/[email protected]
  398. with:
  399. target: ${{ env.DIST_DIR }}/*
  400. parent_folder_id: ${{ secrets.GDRIVE_PARENT_FOLDER_ID }}
  401. child_folder: ${{ env.VERSIONNAME }}
  402. credentials: ${{ secrets.GDRIVE_KEY }}
  403. - name: stable
  404. if: env.IS_TAG == 'true'
  405. uses: softprops/action-gh-release@v2
  406. env:
  407. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  408. with:
  409. files: ${{ env.DIST_DIR }}/*