test_release.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. name: 【测试】自动发行版本
  2. on:
  3. workflow_dispatch:
  4. # push:
  5. # branches:
  6. # - master
  7. jobs:
  8. test-release:
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: write
  12. pages: write
  13. id-token: write
  14. name: 【测试】发行新版本的发行
  15. steps:
  16. - name: 检出代码
  17. uses: actions/checkout@v4
  18. with:
  19. fetch-depth: 0
  20. - name: 检查版本
  21. id: version-check
  22. run: |
  23. VERSION=$(./scripts/is-newer-version.bash)
  24. echo "version=${VERSION}" >> $GITHUB_OUTPUT
  25. if [ "$VERSION" != "0" ]; then
  26. echo "检测到新版本: $VERSION"
  27. else
  28. echo "没有新版本需要发行"
  29. fi
  30. # - name: 推送标签
  31. # if: steps.version-check.outputs.version != '0'
  32. # id: push-tag
  33. # run: |
  34. # tag="v${{ steps.version-check.outputs.version }}"
  35. # git config user.name "${GITHUB_ACTOR}"
  36. # git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  37. # git tag -a "${tag}" -m "Release ${tag}"
  38. # git push origin "${tag}"
  39. # echo "tag_name=${tag}" >> $GITHUB_OUTPUT
  40. - name: 配置环境
  41. if: steps.version-check.outputs.version != '0'
  42. run: |
  43. # 安装 Python 依赖
  44. python3 -m pip install --upgrade pip
  45. pip3 install -r requirements.txt
  46. # 安装构建依赖
  47. sudo apt-get update
  48. sudo apt-get install -y build-essential wget tar gzip
  49. - name: 编译字体
  50. if: steps.version-check.outputs.version != '0'
  51. run: |
  52. # 运行构建脚本
  53. bash build.bash
  54. # 验证输出文件
  55. if [ ! -f "output/xibo.psfu.gz" ]; then
  56. echo "错误:字体文件生成失败"
  57. exit 1
  58. fi
  59. # 显示文件信息
  60. ls -la output/xibo.psfu.gz
  61. - name: Upload artifact
  62. if: (cancelled() || failure() || success())
  63. uses: actions/upload-artifact@v4
  64. with:
  65. path: output/*
  66. compression-level: 9 # maximum compression
  67. retention-days: 5
  68. # - name: 创建 GitHub Release
  69. # if: steps.version-check.outputs.version != '0'
  70. # uses: ncipollo/release-action@v1
  71. # with:
  72. # generateReleaseNotes: true
  73. # tag: "v${{ steps.version-check.outputs.version }}"
  74. # artifacts: "output/xibo.psfu.gz"
  75. # - name: 删除标签(如果失败)
  76. # if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
  77. # run: |
  78. # git config user.name "${GITHUB_ACTOR}"
  79. # git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  80. # git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
  81. # git tag -d "${{ steps.push-tag.outputs.tag_name }}"