Skip to content

Commit d857f0f

Browse files
committed
ci: 배포 성공 시 릴리스 태그(v<버전>) 자동 push 추가
- csproj의 Version을 읽어 v0.x.x 태그 생성, 이미 있으면 스킵 - 태그 push 위해 contents: write 권한으로 변경
1 parent 0dee15b commit d857f0f

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/nuget-publish.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
permissions:
16-
contents: read
16+
contents: write # 릴리스 태그 push용
1717
id-token: write # Trusted Publishing용 GitHub OIDC 토큰 발급 허용
1818

1919
steps:
@@ -49,3 +49,20 @@ jobs:
4949
- name: Publish to NuGet
5050
if: github.ref == 'refs/heads/main' # main 브랜치에서만 배포
5151
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
52+
53+
# 배포된 버전에 릴리스 태그(v<버전>)를 자동으로 push (이미 있으면 스킵)
54+
- name: Tag release
55+
if: github.ref == 'refs/heads/main'
56+
run: |
57+
VERSION=$(grep -oPm1 '(?<=<Version>)[^<]+' src/OpenGJKSharp/OpenGJKSharp.csproj)
58+
if [ -z "$VERSION" ]; then
59+
echo "Version not found in csproj"; exit 1
60+
fi
61+
if git ls-remote --tags origin "refs/tags/v$VERSION" | grep -q .; then
62+
echo "Tag v$VERSION already exists, skipping"
63+
else
64+
git config user.name "github-actions[bot]"
65+
git config user.email "github-actions[bot]@users.noreply.github.com"
66+
git tag -a "v$VERSION" -m "Release v$VERSION"
67+
git push origin "v$VERSION"
68+
fi

0 commit comments

Comments
 (0)