diff --git a/.github/workflows/buid.yaml b/.github/workflows/buid.yaml index f78831c..84d28e4 100644 --- a/.github/workflows/buid.yaml +++ b/.github/workflows/buid.yaml @@ -27,10 +27,21 @@ jobs: with: fetch-depth: 0 - - name: Get branch name + - name: Get tag or branch id: extract_branch shell: bash - run: echo ::set-output name=branch::${GITHUB_REF#refs/heads/} + run: | + latest_tag=$(git describe --tags --abbrev=0 2>/dev/null) + branch=${GITHUB_REF#refs/heads/} + if [[ "$branch" == "master" || "$branch" == "main" ]]; then + ref_name=$branch + elif [[ -n "$latest_tag" ]]; then + ref_name=$latest_tag + else + ref_name=$branch + fi + echo "The ref name is $ref_name" + echo "##[set-output name=branch;]${ref_name}" - name: Setup node env and build uses: actions/setup-node@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f4e5957..9a06a53 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,9 +29,21 @@ jobs: cache: 'yarn' cache-dependency-path: yarn.lock - - name: Extract Tag - id: extract_tag - run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//} + - name: Get tag or branch + id: extract_branch + shell: bash + run: | + latest_tag=$(git describe --tags --abbrev=0 2>/dev/null) + branch=${GITHUB_REF#refs/heads/} + if [[ "$branch" == "master" || "$branch" == "main" ]]; then + ref_name=$branch + elif [[ -n "$latest_tag" ]]; then + ref_name=$latest_tag + else + ref_name=$branch + fi + echo "The ref name is $ref_name" + echo "##[set-output name=branch;]${ref_name}" - name: Build run: |