From 295693f39a5e90e316351017e750145aa3f78211 Mon Sep 17 00:00:00 2001 From: Wei <41205mw@gmail.com> Date: Tue, 17 Sep 2024 17:41:28 +0800 Subject: [PATCH 1/2] Revert "Delete .gitmodules" --- .github/dependabot.yml | 9 ++++----- .gitmodules | 4 ++++ Submodule/github/rest-api-description | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .gitmodules create mode 160000 Submodule/github/rest-api-description diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 26a285de274..d92c5ad8035 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,8 +11,7 @@ updates: schedule: interval: "weekly" -# FIXME: Need other way to update OAS. - # - package-ecosystem: "gitsubmodule" - # directory: "/" - # schedule: - # interval: "weekly" + - package-ecosystem: "gitsubmodule" + directory: "/" + schedule: + interval: "weekly" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..cfdc733eb75 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "Submodule/github/rest-api-description"] + path = Submodule/github/rest-api-description + url = https://github.com/github/rest-api-description.git + shallow = true diff --git a/Submodule/github/rest-api-description b/Submodule/github/rest-api-description new file mode 160000 index 00000000000..38baa7aebf2 --- /dev/null +++ b/Submodule/github/rest-api-description @@ -0,0 +1 @@ +Subproject commit 38baa7aebf29fe927aac6aa0ae769b7a8d3204ca From cc8315ff0ecc1136c75a82e70e4c7c1d2da93dd6 Mon Sep 17 00:00:00 2001 From: Wei18 <41205mw@gmail.com> Date: Tue, 17 Sep 2024 17:42:12 +0800 Subject: [PATCH 2/2] Create .github/workflows/Release.yml --- .github/workflows/Release.yml | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/Release.yml diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 00000000000..cdf920f02ab --- /dev/null +++ b/.github/workflows/Release.yml @@ -0,0 +1,82 @@ +name: Release + +on: + schedule: + - cron: '0 0 1 * *' # 每月的第一天 00:00 UTC + workflow_dispatch: # 允許手動觸發工作流 + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: true + +jobs: + + create-git-branch-release: + runs-on: ubuntu-latest + outputs: + branch: ${{ steps.release_branch.outputs.value }} + steps: + - uses: actions/checkout@v3 # Use the latest stable version + + - name: Create release branch + env: + RELEASE_BRANCH: release + id: release_branch + run: | + git checkout -B $RELEASE_BRANCH + echo "value=$RELEASE_BRANCH" >> $GITHUB_OUTPUT + + - name: Remove submodule (if exists) + env: + SUBMODULE_PATH: Submodule/github/rest-api-description + run: | + if [ -d "$SUBMODULE_PATH" ]; then + git submodule deinit -f $SUBMODULE_PATH || true + git rm -f $SUBMODULE_PATH || true + rm -rf .git/modules/$SUBMODULE_PATH || true + git commit -m "Remove submodule" + git push + else + echo "Submodule not found, skipping removal." + fi + + create-github-release: + needs: create-git-branch-release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get latest version + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + LATEST_VERSION=$(gh release view --repo ${{ github.repository }} --json tagName --jq .tagName) + echo "Latest release version: $LATEST_VERSION" + echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV + + - name: Bump patch version + run: | + # Extract version numbers + VERSION=${LATEST_VERSION#v} + MAJOR=$(echo $VERSION | cut -d. -f1) + MINOR=$(echo $VERSION | cut -d. -f2) + PATCH=$(echo $VERSION | cut -d. -f3) + + # Bump the patch number + PATCH=$((PATCH+1)) + + # Form new version + NEW_VERSION="v$MAJOR.$MINOR.$PATCH" + echo "New version: $NEW_VERSION" + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + + - name: Create new GitHub release + env: + GIT_REF: ${{ needs.create-git-branch-release.outputs.branch }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create $NEW_VERSION \ + --repo ${{ github.repository }} \ + --generate-notes \ + --target "$GIT_REF"