diff --git a/.gitea/workflows/AutoGenerateREADME.yaml b/.gitea/workflows/AutoGenerateREADME.yaml index b09122c..7482a44 100644 --- a/.gitea/workflows/AutoGenerateREADME.yaml +++ b/.gitea/workflows/AutoGenerateREADME.yaml @@ -1,57 +1,57 @@ -name: 自动版本发布 +# name: 自动版本发布 -on: - push: - branches: - - main +# on: +# push: +# branches: +# - main -jobs: - create-readme: - runs-on: ubuntu-latest +# jobs: +# create-readme: +# runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, 'AutoRelease.md')" +# if: "!contains(github.event.head_commit.message, 'AutoRelease.md')" - steps: - - name: 删除本地仓库副本 - env: - REPO_NAME: ${{ github.event.repository.name }} - run: | - if [ -d "$REPO_NAME" ]; then - rm -rf "$REPO_NAME" - fi +# steps: +# - name: 删除本地仓库副本 +# env: +# REPO_NAME: ${{ github.event.repository.name }} +# run: | +# if [ -d "$REPO_NAME" ]; then +# rm -rf "$REPO_NAME" +# fi - - name: 检出仓库 - env: - GITEA_TOKEN: ${{ secrets.AUTOGENERATE }} - GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }} - CLEAN_REPO_URL: ${{ github.server_url }}/${{ github.repository }} - run: | - CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}" - git clone "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" . +# - name: 检出仓库 +# env: +# GITEA_TOKEN: ${{ secrets.AUTOGENERATE }} +# GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }} +# CLEAN_REPO_URL: ${{ github.server_url }}/${{ github.repository }} +# run: | +# CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}" +# git clone "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" . - - name: 生成版本号 - id: version - run: | - VERSION=$(date +'%Y%m%d%H%M%S') - echo "version=$VERSION" >> $GITHUB_OUTPUT +# - name: 生成版本号 +# id: version +# run: | +# VERSION=$(date +'%Y%m%d%H%M%S') +# echo "version=$VERSION" >> $GITHUB_OUTPUT - - name: 创建 Release - run: | - gh release create v${{ steps.version.outputs.version }} --generate-notes +# - name: 创建 Release +# run: | +# gh release create v${{ steps.version.outputs.version }} --generate-notes - - name: 重新提交仓库 - env: - GITEA_TOKEN: ${{ secrets.AUTOGENERATE }} - GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }} - CLEAN_REPO_URL: ${{ github.server_url }}/${{ github.repository }} - run: | - CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}" - git config --local user.email "liyepan@linuxacme.com" - git config --local user.name "iorebuild" - git add README.md - if git diff --staged --quiet; then - echo "No changes to commit." - else - git commit -m "AutoRelease.md" - git push "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" - fi \ No newline at end of file +# - name: 重新提交仓库 +# env: +# GITEA_TOKEN: ${{ secrets.AUTOGENERATE }} +# GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }} +# CLEAN_REPO_URL: ${{ github.server_url }}/${{ github.repository }} +# run: | +# CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}" +# git config --local user.email "liyepan@linuxacme.com" +# git config --local user.name "iorebuild" +# git add README.md +# if git diff --staged --quiet; then +# echo "No changes to commit." +# else +# git commit -m "AutoRelease.md" +# git push "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" +# fi \ No newline at end of file diff --git a/.gitea/workflows/AutoRelease.yaml b/.gitea/workflows/AutoRelease.yaml new file mode 100644 index 0000000..1b38bcd --- /dev/null +++ b/.gitea/workflows/AutoRelease.yaml @@ -0,0 +1,62 @@ +name: 自动版本发布 + +on: + push: + branches: + - main + +jobs: + create-readme: + runs-on: ubuntu-latest + + if: "!contains(github.event.head_commit.message, 'ActionPush')" + + steps: + - name: 删除本地仓库副本 + env: + REPO_NAME: ${{ github.event.repository.name }} + run: | + if [ -d "$REPO_NAME" ]; then + rm -rf "$REPO_NAME" + fi + + - name: 检出仓库 + env: + GITEA_TOKEN: ${{ secrets.AUTOGENERATE }} + GITEA_REPO_URL: ${{ github.server_url }}/${{ github.repository }} + CLEAN_REPO_URL: ${{ github.server_url }}/${{ github.repository }} + run: | + CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}" + git clone "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" . + + - name: 设置 Git 身份 + run: | + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.git.linuxacme.com" + + - name: 生成版本号 + id: version + run: | + # 获取最新的 tag + latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + # 解析主版本号、次版本号和修订号 + major=$(echo $latest_tag | cut -d. -f1 | tr -d 'v') + minor=$(echo $latest_tag | cut -d. -f2) + patch=$(echo $latest_tag | cut -d. -f3) + # 增加修订号 + new_patch=$((patch + 1)) + new_version="v$major.$minor.$new_patch" + echo "::set-output name=version::$new_version" + + - name: 创建新的 tag + run: | + git tag ${{ steps.version.outputs.version }} + git push origin ${{ steps.version.outputs.version }} + + - name: 创建 Release + env: + GITHUB_TOKEN: ${{ secrets.AUTOGENERATE }} + run: | + gh release create ${{ steps.version.outputs.version }} \ + --title "${{ steps.version.outputs.version }} Release" \ + --notes "Automatically generated release for version ${{ steps.version.outputs.version }}" \ No newline at end of file