Skip to content

Commit

Permalink
Fix release.yml to correctly fetch all history including tags during …
Browse files Browse the repository at this point in the history
…code checkout
  • Loading branch information
uyriq committed Oct 28, 2024
1 parent b0c0dcc commit 5a08b15
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,9 @@ jobs:
id: get_previous_tag
shell: pwsh
run: |
# Get all tags sorted by creation date in reverse order
$tags = git tag --sort=-creatordate
# Convert the tags to an array
$tagsArray = $tags -split "`n"
# Get the second latest tag
$prevTag = if ($tagsArray.Length -ge 2) { $tagsArray[1].Trim() } else { "" }
if (-not $prevTag) {
# will do stub
$prevTag = "'v1.2.0'"
}
# Write previous tag to environment file
$prevTag = if ($tagsArray.Length -ge 2) { $tagsArray[1].Trim() } else { "'v1.2.0'" }
Write-Host "Previous tag: $prevTag"
echo "PREV_TAG=$prevTag" >> $env:GITHUB_ENV
Expand All @@ -50,24 +40,30 @@ jobs:
Write-Host "Previous tag: $PREV_TAG"
if ([string]::IsNullOrEmpty($PREV_TAG)) {
Write-Host "No previous tag found. Using fallback."
git log --pretty=format:%s "${GITHUB_REF}~2..${GITHUB_REF}" >> release_notes.md
git log --pretty=format:%s "${GITHUB_REF}~2..${GITHUB_REF}" >> release_notes.md
} else {
git log --pretty=format:%s "$PREV_TAG..${GITHUB_REF}" >> release_notes.md
}
echo "" >> release_notes.md
- name: Extract tag name
id: extract_tag_name
shell: pwsh
run: |
$tagName = "${GITHUB_REF#refs/tags/}"
Write-Host "Tag name: $tagName"
echo "TAG_NAME=$tagName" >> $env:GITHUB_ENV
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
tag_name: ${{ env.TAG_NAME }}
release_name: Release ${{ env.TAG_NAME }}
body_path: ./release_notes.md
draft: false
prerelease: false

- name: Upload PowerShell script
uses: actions/upload-release-asset@v1
Expand Down

0 comments on commit 5a08b15

Please sign in to comment.