Fix git checkout for tag builds in Gitea Actions
- Add conditional logic to handle tag vs branch checkouts - Tags don't exist on 'origin/tagname' so use direct checkout - Branches can be checked out as 'origin/branchname' - Fixes 'fatal: origin/v0.0.1 is not a commit' error
This commit is contained in:
@@ -18,7 +18,11 @@ jobs:
|
|||||||
git init
|
git init
|
||||||
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
||||||
git fetch origin ${{ github.ref }}
|
git fetch origin ${{ github.ref }}
|
||||||
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||||
|
git checkout ${{ github.ref_name }}
|
||||||
|
else
|
||||||
|
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
run: |
|
run: |
|
||||||
@@ -31,7 +35,7 @@ jobs:
|
|||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
VERSION=${{ github.ref_name }}
|
||||||
else
|
else
|
||||||
VERSION=dev-${{ github.sha }}
|
VERSION=dev-${{ github.sha }}
|
||||||
fi
|
fi
|
||||||
@@ -148,7 +152,11 @@ jobs:
|
|||||||
git init
|
git init
|
||||||
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
||||||
git fetch origin ${{ github.ref }}
|
git fetch origin ${{ github.ref }}
|
||||||
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||||
|
git checkout ${{ github.ref_name }}
|
||||||
|
else
|
||||||
|
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Set up Docker
|
- name: Set up Docker
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user