Skip to content

Commit 0fcba46

Browse files
committed
fix: restructure workflow to build after version commit
- Remove @semantic-release/github plugin to avoid immutable releases - Run semantic-release only for non-release commits - Run build/upload/publish jobs only for chore(release) commits - Extract version from package.json instead of job outputs - Fixes issue where binaries couldn't be uploaded to immutable release
1 parent 703ecf7 commit 0fcba46

2 files changed

Lines changed: 24 additions & 38 deletions

File tree

.github/workflows/release.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
# Run semantic-release to create version, changelog, and tag
1010
semantic-release:
11-
# Skip if commit message starts with 'chore(release):'
11+
# Only run if NOT a release commit
1212
if: ${{ !startsWith(github.event.head_commit.message, 'chore(release):') }}
1313
runs-on: ubuntu-latest
1414
outputs:
@@ -81,8 +81,8 @@ jobs:
8181
8282
# Build binaries for multiple platforms
8383
build:
84-
needs: semantic-release
85-
if: needs.semantic-release.outputs.new_release_published == 'true'
84+
# Run only for release commits (when we have the new version)
85+
if: ${{ startsWith(github.event.head_commit.message, 'chore(release):') }}
8686
runs-on: ${{ matrix.os }}
8787
strategy:
8888
matrix:
@@ -103,12 +103,6 @@ jobs:
103103
steps:
104104
- name: Checkout code
105105
uses: actions/checkout@v4
106-
with:
107-
ref: main
108-
fetch-depth: 0
109-
110-
- name: Pull latest changes
111-
run: git pull origin main
112106

113107
- name: Setup Node.js
114108
uses: actions/setup-node@v4
@@ -154,8 +148,8 @@ jobs:
154148

155149
# Upload binaries to the GitHub release
156150
upload-binaries:
157-
needs: [semantic-release, build]
158-
if: needs.semantic-release.outputs.new_release_published == 'true'
151+
needs: build
152+
if: ${{ startsWith(github.event.head_commit.message, 'chore(release):') }}
159153
runs-on: ubuntu-latest
160154
permissions:
161155
contents: write
@@ -176,10 +170,17 @@ jobs:
176170
ls -la ./binaries/
177171
find ./binaries -type f -exec ls -la {} \;
178172
173+
- name: Get version from package.json
174+
id: get_version
175+
run: |
176+
VERSION=$(node -p "require('./package.json').version")
177+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
178+
echo "Version: ${VERSION}"
179+
179180
- name: Upload binaries to release
180181
env:
181182
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
182-
VERSION: ${{ needs.semantic-release.outputs.new_release_version }}
183+
VERSION: ${{ steps.get_version.outputs.version }}
183184
run: |
184185
# Get the release ID for the version tag
185186
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/v${VERSION} --jq '.id' || echo "")
@@ -202,8 +203,8 @@ jobs:
202203
203204
# Publish to other registries and update Homebrew
204205
publish-extras:
205-
needs: semantic-release
206-
if: needs.semantic-release.outputs.new_release_published == 'true'
206+
needs: upload-binaries
207+
if: ${{ startsWith(github.event.head_commit.message, 'chore(release):') }}
207208
runs-on: ubuntu-latest
208209
steps:
209210
- name: Checkout code
@@ -216,10 +217,17 @@ jobs:
216217
with:
217218
node-version: '20'
218219

220+
- name: Get version from package.json
221+
id: get_version
222+
run: |
223+
VERSION=$(node -p "require('./package.json').version")
224+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
225+
echo "Version: ${VERSION}"
226+
219227
- name: Publish to GitHub Packages
220228
env:
221229
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222-
VERSION: ${{ needs.semantic-release.outputs.new_release_version }}
230+
VERSION: ${{ steps.get_version.outputs.version }}
223231
run: |
224232
echo "Publishing version ${VERSION} to GitHub Packages..."
225233
@@ -248,7 +256,7 @@ jobs:
248256
- name: Update Homebrew Tap
249257
env:
250258
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
251-
VERSION: ${{ needs.semantic-release.outputs.new_release_version }}
259+
VERSION: ${{ steps.get_version.outputs.version }}
252260
run: |
253261
# Check if GH_TOKEN is available
254262
if [ -z "$GITHUB_TOKEN" ]; then

package.json

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -109,28 +109,6 @@
109109
],
110110
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
111111
}
112-
],
113-
[
114-
"@semantic-release/github",
115-
{
116-
"assets": [
117-
{
118-
"path": "binaries/gh-manager-cli-linux-x64/gh-manager-cli-linux-x64",
119-
"name": "gh-manager-cli-linux-x64",
120-
"label": "Linux x64 Binary"
121-
},
122-
{
123-
"path": "binaries/gh-manager-cli-macos-x64/gh-manager-cli-macos-x64",
124-
"name": "gh-manager-cli-macos-x64",
125-
"label": "macOS x64 Binary"
126-
},
127-
{
128-
"path": "binaries/gh-manager-cli-windows-x64/gh-manager-cli-windows-x64.exe",
129-
"name": "gh-manager-cli-windows-x64.exe",
130-
"label": "Windows x64 Binary"
131-
}
132-
]
133-
}
134112
]
135113
]
136114
}

0 commit comments

Comments
 (0)