From 3a1f4f204a6127e70ecf7d796fe70a0e5c20decd Mon Sep 17 00:00:00 2001 From: Lea Date: Sat, 29 Jul 2023 21:29:21 +0200 Subject: [PATCH] Create workflow to build CSS releases --- .forgejo/workflows/build-and-release.yaml | 44 +++++++++++++++++++++++ build.sh | 7 ++++ 2 files changed, 51 insertions(+) create mode 100644 .forgejo/workflows/build-and-release.yaml diff --git a/.forgejo/workflows/build-and-release.yaml b/.forgejo/workflows/build-and-release.yaml new file mode 100644 index 0000000..7212dcf --- /dev/null +++ b/.forgejo/workflows/build-and-release.yaml @@ -0,0 +1,44 @@ +name: Build and release + +on: + push: + branches: [master] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Install lessc + run: npm install -g less + + - name: Check out repository + uses: actions/checkout@v3 + + - name: Parse commit hash + run: echo "RELEASE_TAG=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV + + - name: Build CSS + run: | + mkdir dist + ./build.sh + tar -C dist -cvf themes.tar . + mv themes.tar dist + id: build + + - name: Publish release + uses: actions/forgejo-release@v1 + with: + direction: upload + release-dir: dist + token: ${{ github.token }} + tag: $RELEASE_TAG + release-notes: | + Automatic release triggered by commit ${{ github.sha }} + + Add the following to \`app.ini\`: + \`\`\`ini + [ui] + THEMES = ${{ steps.build.outputs.themes }} + \`\`\` + + And download the CSS files from this release to \`\$GITEA_DATA_DIR/gitea/public/css\`. [\`themes.tar\`](/Lea/gitea-themes/releases/download/$RELEASE_TAG/themes.tar) contains all CSS files for convenience. diff --git a/build.sh b/build.sh index 3eaa563..d5db74d 100755 --- a/build.sh +++ b/build.sh @@ -3,12 +3,19 @@ BASEDIR="$( cd "$( dirname "$0" )" && pwd )" cd "${BASEDIR}" +theme_list="" + for theme in edge gruvbox gruvbox-material everforest; do for variant in dark light auto; do + theme_list="$theme_list,$theme-$variant" lessc -x "src/${theme}-${variant}.less" > "dist/theme-${theme}-${variant}.css" done done for theme in nord palenight soft-era sonokai sonokai-andromeda sonokai-atlantis sonokai-espresso sonokai-maia sonokai-shusia; do + theme_list="$theme_list,$theme" lessc -x "src/${theme}.less" > "dist/theme-${theme}.css" done + +# First character in theme_list will be a comma, let's remove that +echo "themes=${theme_list:1}" >> $GITHUB_OUTPUT