diff --git a/.github/workflows/build-nightly.yml b/.github/workflows/build-nightly.yml index 48158a49..add302cb 100644 --- a/.github/workflows/build-nightly.yml +++ b/.github/workflows/build-nightly.yml @@ -78,19 +78,12 @@ jobs: run: pnpm install --frozen-lockfile - name: Build UI + id: build_ui run: | make build-frontend + echo "ui_tarball=$(make -s pack-frontend)" >> $GITHUB_ENV - - name: Pack UI - id: pack - run: | - mkdir -p ./local/artalk_ui - cp -r ./public/dist ./public/sidebar ./local/artalk_ui - - mkdir -p ./local/nightly_includes - tar -czf ./local/nightly_includes/artalk_ui_nightly.tar.gz -C ./local artalk_ui - - - name: Upload UI + - name: Upload UI dist uses: actions/upload-artifact@v4 with: name: ui-src @@ -100,11 +93,12 @@ jobs: if-no-files-found: error retention-days: 1 - - name: Upload UI package + - name: Upload UI tarball (included in release) uses: actions/upload-artifact@v4 with: - name: build-ui-pkg - path: local/nightly_includes/artalk_ui_nightly.tar.gz + name: build-ui-tarball + path: ${{ steps.build_ui.outputs.ui_tarball }} + if-no-files-found: error retention-days: 1 # diff --git a/.goreleaser.yml b/.goreleaser.yml index 3ea3fe73..6264c0aa 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -17,6 +17,7 @@ before: # install dependencies - make install - make build-frontend + - make pack-frontend # build multi-platform builds: diff --git a/Makefile b/Makefile index 0e16f0f6..0130cf74 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,10 @@ build: $(PKG_NAME) build-frontend: - ./scripts/build-frontend.sh + @./scripts/build-frontend.sh + +pack-frontend: + @./scripts/pack-frontend.sh build-debug: @echo "Building Artalk for debugging..." @@ -73,7 +76,7 @@ docker-build: docker-push: ./scripts/docker-build.sh --push -.PHONY: all install run build build-frontend build-debug dev \ +.PHONY: all install run build build-frontend pack-frontend build-debug dev \ test test-coverage test-coverage-html test-frontend-e2e \ update-i18n update-conf update-conf-docs \ update-docs-features update-swagger \ diff --git a/scripts/build-frontend.sh b/scripts/build-frontend.sh index f3488572..7277ce61 100755 --- a/scripts/build-frontend.sh +++ b/scripts/build-frontend.sh @@ -2,7 +2,7 @@ set -e -if ! command -v pnpm &> /dev/null +if ! command -v pnpm &>/dev/null && command -v apt-get &>/dev/null; then apt-get update && apt-get install --no-install-recommends -y -q curl ca-certificates @@ -15,36 +15,26 @@ then volta install pnpm@9.10.0 fi +# build pnpm install --frozen-lockfile pnpm build:all +pnpm build:auth ## dist folders DIST_DIR="./public/dist" +I18N_DIR="./public/dist/i18n" SIDEBAR_DIR="./public/sidebar" +PLUGIN_DIR="./public/dist/plugins" -## dist +# clean rm -rf ${DIST_DIR} && mkdir -p ${DIST_DIR} -cp -r ./ui/artalk/dist/{Artalk.css,Artalk.js} ${DIST_DIR} -cp -r ./ui/artalk/dist/{ArtalkLite.css,ArtalkLite.js} ${DIST_DIR} - -I18N_DIR="${DIST_DIR}/i18n" -mkdir -p ${I18N_DIR} -cp -r ./ui/artalk/dist/i18n/*.js ${I18N_DIR} - -## sidebar +rm -rf ${I18N_DIR} && mkdir -p ${I18N_DIR} rm -rf ${SIDEBAR_DIR} && mkdir -p ${SIDEBAR_DIR} -cp -r ./ui/artalk-sidebar/dist/* ${SIDEBAR_DIR} - -## plugins -PLUGIN_DIR="${DIST_DIR}/plugins" -mkdir -p ${PLUGIN_DIR} +rm -rf ${PLUGIN_DIR} && mkdir -p ${PLUGIN_DIR} -pnpm build:auth -cp -r ./ui/plugin-auth/dist/artalk-plugin-auth.js ${PLUGIN_DIR} - -## create tarball for release -mkdir -p ./local/artalk_ui -cp -r ${DIST_DIR} ${SIDEBAR_DIR} ./local/artalk_ui - -mkdir -p ./local/release_includes -tar -czf ./local/release_includes/artalk_ui.tar.gz -C ./local artalk_ui +## copy +cp ./ui/artalk/dist/{Artalk.css,Artalk.js} ${DIST_DIR} +cp ./ui/artalk/dist/{ArtalkLite.css,ArtalkLite.js} ${DIST_DIR} +cp ./ui/artalk/dist/i18n/*.js ${I18N_DIR} +cp -r ./ui/artalk-sidebar/dist/* ${SIDEBAR_DIR} +cp ./ui/plugin-*/dist/*.js ${PLUGIN_DIR} diff --git a/scripts/pack-frontend.sh b/scripts/pack-frontend.sh new file mode 100755 index 00000000..741b57fc --- /dev/null +++ b/scripts/pack-frontend.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +rm -rf ./local/artalk_ui && mkdir -p ./local/artalk_ui +cp -r ./public/* ./local/artalk_ui + +mkdir -p ./local/release_includes +tar -czf ./local/release_includes/artalk_ui.tar.gz -C ./local artalk_ui + +echo $(realpath ./local/release_includes/artalk_ui.tar.gz)