57 lines
1.8 KiB
YAML
57 lines
1.8 KiB
YAML
name: 自动版本发布
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
create-readme:
|
|
runs-on: ubuntu-latest
|
|
|
|
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
|
|
|
|
- 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: 创建 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 |