From c209afdaa1b98885b40d09e9518b47453f3d8d3a Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 8 Sep 2023 10:51:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 29 ++++++++++++++++++++++++----- source/cli/main.cpp | 1 + 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 839c7e32..1e949480 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,13 +30,32 @@ on: jobs: meta: runs-on: ubuntu-latest - outputs: - tag: ${{ steps.set_tag.outputs.tag }} steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - id: set_tag run: | - echo tag=$(git describe --tags --match "v*" ${{ github.ref }} || git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT + is_release=${{ startsWith(github.ref, 'refs/tags/v') }} + tag=$(git describe --tags --match "v*" ${{ github.ref }} || true) + if [[ $tag != v* ]]; then + tag=$(curl -sX GET "https://api.github.com/repos/MaaAssistantArknights/MaaFramework/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]') + if [[ $tag != v* ]]; then + tag="v0.0.0" + fi + tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)") + fi + if ! $($is_release) ; then + prefix=${tag%-*-*} + suffix=${tag#$prefix-} + tag="$prefix-ci.$suffix" + fi + + echo tag=$tag | tee -a $GITHUB_OUTPUT + echo is_release=$is_release | tee -a $GITHUB_OUTPUT + outputs: + tag: ${{ steps.set_tag.outputs.tag }} + is_release: ${{ steps.set_tag.outputs.is_release }} windows: needs: meta @@ -213,8 +232,8 @@ jobs: path: "install" release: - if: startsWith(github.ref, 'refs/tags/v') - needs: [meta, windows] + if: ${{ needs.meta.outputs.is_release == 'true' }} + needs: [meta, windows, ubuntu, macos] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 diff --git a/source/cli/main.cpp b/source/cli/main.cpp index 4606c59b..40cf0a1c 100644 --- a/source/cli/main.cpp +++ b/source/cli/main.cpp @@ -1,3 +1,4 @@ +#include #include #include #include