Skip to content

Commit d695e49

Browse files
Brandon Hclaude
andcommitted
fix: resolve semantic-release workflow configuration issues
- Remove unsupported releaseBodyTemplate from GitHub plugin configuration - Improve release detection logic to identify newly created tags - Add proper conditional checks for binary building and asset upload - Ensure workflow gracefully handles cases where no release is created This fixes the semantic-release workflow failure and ensures the automated binary building only occurs when a new release is actually created. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent acb9dfa commit d695e49

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

.github/workflows/semantic-release.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,34 @@ jobs:
6363
- name: Get release version
6464
id: version
6565
run: |
66-
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
67-
if [ -n "$VERSION" ]; then
68-
echo "VERSION=${VERSION}" >> $GITHUB_ENV
69-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
70-
echo "Release version: $VERSION"
66+
# Get the latest tag created in this run
67+
LATEST_TAG=$(git tag --sort=-version:refname | head -n1 2>/dev/null || echo "")
68+
# Check if this tag was created in the last minute (indicating it was just created by semantic-release)
69+
if [ -n "$LATEST_TAG" ]; then
70+
TAG_DATE=$(git log -1 --format=%ct "$LATEST_TAG" 2>/dev/null || echo "0")
71+
CURRENT_TIME=$(date +%s)
72+
TIME_DIFF=$((CURRENT_TIME - TAG_DATE))
73+
74+
if [ $TIME_DIFF -lt 300 ]; then # Tag created in last 5 minutes
75+
echo "VERSION=${LATEST_TAG}" >> $GITHUB_ENV
76+
echo "version=${LATEST_TAG}" >> $GITHUB_OUTPUT
77+
echo "New release detected: $LATEST_TAG"
78+
echo "HAS_RELEASE=true" >> $GITHUB_ENV
79+
else
80+
echo "No new release created in this run"
81+
echo "HAS_RELEASE=false" >> $GITHUB_ENV
82+
fi
7183
else
72-
echo "No new release created"
73-
exit 0
84+
echo "No tags found"
85+
echo "HAS_RELEASE=false" >> $GITHUB_ENV
7486
fi
7587
7688
- name: Build release binaries
77-
if: env.VERSION
89+
if: env.HAS_RELEASE == 'true'
7890
run: VERSION=${{ env.VERSION }} make dist
7991

8092
- name: Upload release assets
81-
if: env.VERSION
93+
if: env.HAS_RELEASE == 'true'
8294
env:
8395
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8496
run: |

.releaserc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
[
5353
"@semantic-release/github",
5454
{
55-
"addReleases": "bottom",
56-
"releaseBodyTemplate": "## Release ${nextRelease.version}\n\nCross-platform binaries and source code for hosts-manager.\n\n### 📦 Available Downloads\n\n**Compiled Binaries (both .tar.gz and .zip formats):**\n- `hosts-manager-${nextRelease.version}-linux-amd64.{tar.gz,zip}` - Linux x64\n- `hosts-manager-${nextRelease.version}-linux-arm64.{tar.gz,zip}` - Linux ARM64\n- `hosts-manager-${nextRelease.version}-darwin-amd64.{tar.gz,zip}` - macOS Intel\n- `hosts-manager-${nextRelease.version}-darwin-arm64.{tar.gz,zip}` - macOS Apple Silicon\n- `hosts-manager-${nextRelease.version}-windows-amd64.{tar.gz,zip}` - Windows x64\n\n**Source Code:**\n- `hosts-manager-${nextRelease.version}-source.tar.gz` - Complete source code archive\n- `hosts-manager-${nextRelease.version}-source.zip` - Complete source code archive\n\n### 🚀 Quick Installation\n\n**Linux/macOS:**\n```bash\n# Download and extract (replace with your platform)\ncurl -L -o hosts-manager.tar.gz https://github.com/${process.env.GITHUB_REPOSITORY}/releases/download/${nextRelease.version}/hosts-manager-${nextRelease.version}-linux-amd64.tar.gz\ntar -xzf hosts-manager.tar.gz\nsudo mv hosts-manager /usr/local/bin/hosts-manager\nchmod +x /usr/local/bin/hosts-manager\n```\n\n**Windows:**\nDownload the appropriate `.zip` file for your architecture and add the extracted `hosts-manager.exe` to your PATH.\n\n### 🔐 Checksums\nAll files are verified with SHA-256 checksums in `checksums.txt`.\n\n---\n\n${releaseNotes}"
55+
"addReleases": "bottom"
5756
}
5857
],
5958
[

0 commit comments

Comments
 (0)