From c0163fb16ea4acd2f4712efd743e2a397ed81038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sat, 3 Aug 2024 23:16:10 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/delete_tags_and_releases.py | 22 ++++++++++++++ .github/workflows/clear.yml | 29 +++++++++++++++++++ .github/workflows/release.yml | 29 +++++++++++++++---- .gitignore | 2 +- app/index/controller/Index.php | 2 +- bin/clearTag.cmd | 11 +++++++ .../.github/workflows/release.yml | 26 +++++++++++++++++ readme.md | 2 +- 8 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 .github/delete_tags_and_releases.py create mode 100644 .github/workflows/clear.yml create mode 100644 bin/clearTag.cmd create mode 100644 plugin/think-plugs-static/.github/workflows/release.yml diff --git a/.github/delete_tags_and_releases.py b/.github/delete_tags_and_releases.py new file mode 100644 index 000000000..3ade0aa76 --- /dev/null +++ b/.github/delete_tags_and_releases.py @@ -0,0 +1,22 @@ +import os +from github import Github + +def delete_all_releases(repo): + for release in repo.get_releases(): + try: + release.delete_release() + print(f"Deleted release: {release.title}") + except Exception as e: + print(f"Failed to delete release {release.title}: {e}") + +def main(): + token = os.getenv("GITHUB_TOKEN") + repo_name = os.getenv("GITHUB_REPOSITORY").split('/')[-1] # 获取仓库名 + owner = os.getenv("GITHUB_REPOSITORY").split('/')[0] # 获取仓库所有者 + g = Github(token) + repo = g.get_repo(f"{owner}/{repo_name}") + + delete_all_releases(repo) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/.github/workflows/clear.yml b/.github/workflows/clear.yml new file mode 100644 index 000000000..9632642ff --- /dev/null +++ b/.github/workflows/clear.yml @@ -0,0 +1,29 @@ +name: Clear Release + +on: + workflow_dispatch: + +jobs: + delete: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install PyGithub + run: pip install PyGithub + + - name: Delete all GitHub tags + run: | + # 获取所有 tag 的列表 + TAGS=$(git ls-remote --tags origin | cut -f2 | cut -d'/' -f3) + + # 循环遍历所有 tag 并删除 + for TAG in $TAGS; do + curl -s -X DELETE "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$TAG" -H "Authorization: token ${{ secrets.TOKEN }}" + done \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94c8d25c0..0b4f02cb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,23 +4,42 @@ on: tags: - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 -name: Release +name: Create Release permissions: write-all jobs: release: - name: Release runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 16 + + - name: Install dependencies + run: npm install -g conventional-changelog-cli + + - name: Find last tag + id: last_tag + run: echo "::set-output name=tag::$(git describe --tags --abbrev=0 || echo 'v0.0.0')" + + - name: Generate changelog since last tag + run: | + conventional-changelog -p angular -i CHANGELOG.md -s -r ${{ steps.last_tag.outputs.tag }}..HEAD + - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.TOKEN }} with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + tag_name: ${{ steps.last_tag.outputs.tag }} + release_name: Release ${{ steps.last_tag.outputs.tag }} + body_path: CHANGELOG.md draft: false - prerelease: false + prerelease: false \ No newline at end of file diff --git a/.gitignore b/.gitignore index d187db279..d23251979 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ .fleet .vscode .DS_Store - + /vendor /runtime /safefile diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 2f5fbf79c..616a90660 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -21,7 +21,7 @@ use think\admin\Controller; class Index extends Controller { public function index() - { + { $this->redirect(sysuri('admin/login/index')); } } diff --git a/bin/clearTag.cmd b/bin/clearTag.cmd new file mode 100644 index 000000000..93db0c581 --- /dev/null +++ b/bin/clearTag.cmd @@ -0,0 +1,11 @@ +@echo off +setlocal + +echo Deleting remote tags... +for /f "delims=" %%x in ('git tag') do git push --delete origin %%x + +echo Deleting local tags... +for /f "delims=" %%i in ('git tag') do git tag -d %%i + +echo All tags deleted. +pause \ No newline at end of file diff --git a/plugin/think-plugs-static/.github/workflows/release.yml b/plugin/think-plugs-static/.github/workflows/release.yml new file mode 100644 index 000000000..94c8d25c0 --- /dev/null +++ b/plugin/think-plugs-static/.github/workflows/release.yml @@ -0,0 +1,26 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Release +permissions: write-all + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false diff --git a/readme.md b/readme.md index ac6b81a4a..4ceaaac35 100644 --- a/readme.md +++ b/readme.md @@ -17,7 +17,7 @@ composer update --optimize-autoloader # 运行本地测试环境,启用 8088 商品 php think run --host 127.0.0.1 --port 8088 -# 打开浏览器访问网站 ( Windows ) +# 打开浏览器访问网站 ( Windows ) start http://127.0.0.1:8088 ```