From 8746ad8f9c69078354eb8fa937cc411bcd0837d5 Mon Sep 17 00:00:00 2001 From: minoplhy Date: Thu, 10 Oct 2024 22:09:45 +0700 Subject: [PATCH] enhance code quality --- .github/workflows/forgejo-build.yaml | 46 ++++++++++++++++++++ .github/workflows/freenginx-build.yaml | 56 +++++++++++++----------- .github/workflows/gitea-build.yaml | 11 +---- .github/workflows/nginx-build.yaml | 60 +++++++++++++++----------- 4 files changed, 114 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/forgejo-build.yaml diff --git a/.github/workflows/forgejo-build.yaml b/.github/workflows/forgejo-build.yaml new file mode 100644 index 0000000..2d86086 --- /dev/null +++ b/.github/workflows/forgejo-build.yaml @@ -0,0 +1,46 @@ +name: forgejo Mega Build +run-name: forgejo Build +on: + push: + tags: + - forgejo-* +jobs: + build_forgejo: + runs-on: [ubuntu-latest] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up environment variables + run: | + TAG_NAME=${GITHUB_REF##*/} + GITEA_TAG=${TAG_NAME#forgejo-} + + echo "GITEA_TAG=${GITEA_TAG}" >> $GITHUB_ENV + echo "GITEA_TAG=${GITEA_TAG}" + + - name: Setup Package Directory + run: | + sudo mkdir -p /gitea-${GITEA_TAG} + + - name: Run forgejo Build (binary + static) + run: | + echo "This Task will be run using the following tag: ${GITEA_TAG}" + curl -L https://github.com/minoplhy/scriptbox/raw/main/build_gitea/Linux/build.sh | bash -s -- --git-tag "${GITEA_TAG}" --static --type=forgejo + + # Copy forgejo to package directory(this is due to a broken mechanism in origin script) + sudo cp ~/gitea-binaries/gitea /forgejo-${GITEA_TAG}/gitea + sudo cp -r ~/gitea-binaries/gitea-static /forgejo-${GITEA_TAG}/gitea-static + + - name: Zip Package + run: | + sudo tar czvf forgejo-${GITEA_TAG}.tar.gz /forgejo-${GITEA_TAG} + + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + body: | + "forgejo Successfully build on -> ${{ env.GITEA_TAG }}" + token: ${{ secrets.DEPLOYMENT_TOKEN }} + files: forgejo-*.tar.gz diff --git a/.github/workflows/freenginx-build.yaml b/.github/workflows/freenginx-build.yaml index e84a123..8974bce 100644 --- a/.github/workflows/freenginx-build.yaml +++ b/.github/workflows/freenginx-build.yaml @@ -18,30 +18,38 @@ jobs: echo "NGINX_TAG=${NGINX_TAG}" >> $GITHUB_ENV echo "NGINX_TAG=${NGINX_TAG}" + + TAGS=("vanilla" "allstar" "lua" "modsecurity") + OPTIONS=( + "--type=freenginx" + "--lua --type=freenginx" + "--lua --type=freenginx" + "--modsecurity --type=freenginx" + ) + + - name: Run freenginx Builds + run: | + for i in ${!TAGS[@]}; do + echo "This Task will be run using the following tag: ${NGINX_TAG}" + curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} ${OPTIONS[$i]} - - name: Run freenginx Build (Vanilla) - run: | - echo "This Task will be run using the following tag: ${NGINX_TAG}" - curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} --no-lua --no-modsecurity --type=freenginx - tar czvf nginx-${NGINX_TAG}-vanilla.tar.gz ~/nginx_scriptbox/nginx/objs - - - name: Run freenginx Build (All Star) - run: | - echo "This Task will be run using the following tag: ${NGINX_TAG}" - curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} --type=freenginx - tar czvf nginx-${NGINX_TAG}-allstar.tar.gz ~/nginx_scriptbox/nginx/objs /opt/nginx-lua-module /usr/local/lua /usr/local/modsecurity - - - name: Run freenginx Build (Lua) - run: | - echo "This Task will be run using the following tag: ${NGINX_TAG}" - curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} --no-modsecurity --type=freenginx - tar czvf nginx-${NGINX_TAG}-lua.tar.gz ~/nginx_scriptbox/nginx/objs /opt/nginx-lua-module /usr/local/lua - - - name: Run freenginx Build (ModSecurity) - run: | - echo "This Task will be run using the following tag: ${NGINX_TAG}" - curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} --no-lua --type=freenginx - tar czvf nginx-${NGINX_TAG}-modsecurity.tar.gz ~/nginx_scriptbox/nginx/objs /usr/local/modsecurity + # Prepare tar file paths + TAR_PATH="~/nginx_scriptbox/nginx/objs" # Base Path + case "${TAGS[$i]}" in + "allstar") + TAR_PATH="$TAR_PATH /opt/nginx-lua-module /usr/local/lua /usr/local/modsecurity" + ;; + "lua") + TAR_PATH="$TAR_PATH /opt/nginx-lua-module /usr/local/lua" + ;; + "modsecurity") + TAR_PATH="$TAR_PATH /usr/local/modsecurity" + ;; + esac + + # Create the tarball + tar czvf freenginx-${NGINX_TAG}-${TAGS[$i]}.tar.gz $TAR_PATH + done - name: Release uses: softprops/action-gh-release@v2 @@ -50,4 +58,4 @@ jobs: body: | "freenginx Successfully build on -> ${{ env.NGINX_TAG }}" token: ${{ secrets.DEPLOYMENT_TOKEN }} - files: nginx-*.tar.gz + files: freenginx-*.tar.gz diff --git a/.github/workflows/gitea-build.yaml b/.github/workflows/gitea-build.yaml index 44aa871..37b67a4 100644 --- a/.github/workflows/gitea-build.yaml +++ b/.github/workflows/gitea-build.yaml @@ -23,20 +23,13 @@ jobs: run: | sudo mkdir -p /gitea-${GITEA_TAG} - - name: Run Gitea Build (binary) + - name: Run Gitea Build (binary + static) run: | echo "This Task will be run using the following tag: ${GITEA_TAG}" - curl -L https://github.com/minoplhy/scriptbox/raw/main/build_gitea/Linux/build.sh | bash -s -- --git-tag "${GITEA_TAG}" + curl -L https://github.com/minoplhy/scriptbox/raw/main/build_gitea/Linux/build.sh | bash -s -- --git-tag "${GITEA_TAG}" --static --type=gitea # Copy gitea to package directory(this is due to a broken mechanism in origin script) sudo cp ~/gitea-binaries/gitea /gitea-${GITEA_TAG}/gitea - - - name: Run Gitea Build (static) - run: | - echo "This Task will be run using the following tag: ${GITEA_TAG}" - curl -L https://github.com/minoplhy/scriptbox/raw/main/build_gitea/Linux/build.sh | bash -s -- --git-tag "${GITEA_TAG}" --static - - # Copy gitea to package directory(this is due to a broken mechanism in origin script) sudo cp -r ~/gitea-binaries/gitea-static /gitea-${GITEA_TAG}/gitea-static - name: Zip Package diff --git a/.github/workflows/nginx-build.yaml b/.github/workflows/nginx-build.yaml index 2523737..4d7912b 100644 --- a/.github/workflows/nginx-build.yaml +++ b/.github/workflows/nginx-build.yaml @@ -1,5 +1,5 @@ -name: Nginx Mega Build -run-name: Nginx Build +name: nginx Mega Build +run-name: nginx Build on: push: tags: @@ -18,36 +18,44 @@ jobs: echo "NGINX_TAG=${NGINX_TAG}" >> $GITHUB_ENV echo "NGINX_TAG=${NGINX_TAG}" + + TAGS=("vanilla" "allstar" "lua" "modsecurity") + OPTIONS=( + "--type=nginx" + "--lua --type=nginx" + "--lua --type=nginx" + "--modsecurity --type=nginx" + ) + + - name: Run nginx Builds + run: | + for i in ${!TAGS[@]}; do + echo "This Task will be run using the following tag: ${NGINX_TAG}" + curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} ${OPTIONS[$i]} - - name: Run Nginx Build (Vanilla) - run: | - echo "This Task will be run using the following tag: ${NGINX_TAG}" - curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} --no-lua --no-modsecurity --type=nginx - tar czvf nginx-${NGINX_TAG}-vanilla.tar.gz ~/nginx_scriptbox/nginx/objs - - - name: Run Nginx Build (All Star) - run: | - echo "This Task will be run using the following tag: ${NGINX_TAG}" - curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} --type=nginx - tar czvf nginx-${NGINX_TAG}-allstar.tar.gz ~/nginx_scriptbox/nginx/objs /opt/nginx-lua-module /usr/local/lua /usr/local/modsecurity - - - name: Run Nginx Build (Lua) - run: | - echo "This Task will be run using the following tag: ${NGINX_TAG}" - curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} --no-modsecurity --type=nginx - tar czvf nginx-${NGINX_TAG}-lua.tar.gz ~/nginx_scriptbox/nginx/objs /opt/nginx-lua-module /usr/local/lua - - - name: Run Nginx Build (ModSecurity) - run: | - echo "This Task will be run using the following tag: ${NGINX_TAG}" - curl https://raw.githubusercontent.com/minoplhy/scriptbox/main/nginx_build_script/build.sh | bash -s -- --nginx-tag=${NGINX_TAG} --no-lua --type=nginx - tar czvf nginx-${NGINX_TAG}-modsecurity.tar.gz ~/nginx_scriptbox/nginx/objs /usr/local/modsecurity + # Prepare tar file paths + TAR_PATH="~/nginx_scriptbox/nginx/objs" # Base Path + case "${TAGS[$i]}" in + "allstar") + TAR_PATH="$TAR_PATH /opt/nginx-lua-module /usr/local/lua /usr/local/modsecurity" + ;; + "lua") + TAR_PATH="$TAR_PATH /opt/nginx-lua-module /usr/local/lua" + ;; + "modsecurity") + TAR_PATH="$TAR_PATH /usr/local/modsecurity" + ;; + esac + + # Create the tarball + tar czvf nginx-${NGINX_TAG}-${TAGS[$i]}.tar.gz $TAR_PATH + done - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: body: | - "Nginx Successfully build on -> ${{ env.NGINX_TAG }}" + "nginx Successfully build on -> ${{ env.NGINX_TAG }}" token: ${{ secrets.DEPLOYMENT_TOKEN }} files: nginx-*.tar.gz