From 8f2b107eabda8c86332e4e468db265857b81e8d9 Mon Sep 17 00:00:00 2001 From: CDCDDCDC <792192820@qq.com> Date: Tue, 8 Jul 2025 19:46:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0github=20action=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..ae47a8318 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,63 @@ +name: release-ubuntu + +on: + push: + tags: + - "v*.*.*" # 触发条件是推送标签 如git tag v2.7.4 git push origin v2.7.4 + +jobs: + build-ubuntu: + runs-on: ubuntu-latest + strategy: + matrix: + arch: [amd64, arm64] + max-parallel: 1 # 最大并行数 这样amd和arm的打包不会互相影响 + steps: + - name: Checkout + uses: actions/checkout@v4 # github action运行环境 + + - name: Create release # 创建文件夹 + run: | + rm -rf release + mkdir release + echo ${{ github.sha }} > Release.txt + cp Release.txt LICENSE release/ + cat Release.txt + + - name: Set up JDK 1.8 + uses: actions/setup-java@v4 + with: + # Eclipse基金会维护的开源Java发行版 因为github action参考java的用这个 所以用这个 + # 还有microsoft(微软维护的openjdk发行版) oracle(商用SDK)等 + distribution: 'temurin' + java-version: '8' + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' # Node.js版本 20系列的最新稳定版 + + - name: Compile backend + run: | + mvn package + mvn package -P war + + - name: Compile frontend + run: | + cd ./web + npm install + npm run build:prod + cd ../ + + - name: Package Files + run: | + cp -r ./src/main/resources/static release/ # 复制前端文件 + cp ./target/*.jar release/ # 复制 JAR 文件 + cp ./src/main/resources/application-dev.yml release + zip -r release-ubuntu-${{ matrix.arch }}.zip release + + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: release-ubuntu-${{ matrix.arch }}.zip \ No newline at end of file From 67ef8ed8f074490047175b6bb053e2cac6b55585 Mon Sep 17 00:00:00 2001 From: CDCDDCDC <792192820@qq.com> Date: Wed, 9 Jul 2025 12:46:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9github=20action=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=8E=8B=E7=BC=A9=E5=8C=85=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae47a8318..b20761e90 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,8 +10,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - arch: [amd64, arm64] - max-parallel: 1 # 最大并行数 这样amd和arm的打包不会互相影响 + arch: [amd64] + max-parallel: 1 # 最大并行数 steps: - name: Checkout uses: actions/checkout@v4 # github action运行环境 @@ -54,10 +54,23 @@ jobs: cp -r ./src/main/resources/static release/ # 复制前端文件 cp ./target/*.jar release/ # 复制 JAR 文件 cp ./src/main/resources/application-dev.yml release - zip -r release-ubuntu-${{ matrix.arch }}.zip release + + BRANCH=${{ github.event.base_ref }} + BRANCH_NAME=$(echo "$BRANCH" | grep -oP 'refs/heads/\K.*') + echo "BRANCH_NAME= ${BRANCH_NAME}" + # 如果无法获取,使用默认分支 + if [[ -z "BRANCH_NAME" ]]; then + BRANCH_NAME="${{ github.event.repository.default_branch }}" + fi + + TAG_NAME="${GITHUB_REF#refs/tags/}" + DATE=$(date +%Y%m%d) + ZIP_FILE_NAME="${BRANCH_NAME}-${TAG_NAME}-${DATE}.zip" + zip -r "$ZIP_FILE_NAME" release + echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: - files: release-ubuntu-${{ matrix.arch }}.zip \ No newline at end of file + files: ${{ env.ZIP_FILE_NAME }} \ No newline at end of file