Skip to content

Commit c7467aa

Browse files
RahulHereRahulHere
authored andcommitted
Fix GitHub Release permissions and version propagation
- Add explicit permissions for contents:write and packages:write at workflow level - Set LIB_VERSION as global environment variable from inputs or default (0.1.0) - Simplify version configuration to use global env variable consistently - Fix release tag generation to use the global LIB_VERSION - Remove dependency on passing version between jobs via GITHUB_ENV This ensures the release creation has proper permissions and the version is correctly propagated throughout the workflow.
1 parent a4619a1 commit c7467aa

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

.github/workflows/build-all.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ on:
2424
default: true
2525
type: boolean
2626

27+
permissions:
28+
contents: write
29+
packages: write
30+
2731
env:
2832
BUILD_TYPE: ${{ github.event.inputs.build_type || 'Release' }}
33+
LIB_VERSION: ${{ github.event.inputs.version || '0.1.0' }}
2934

3035
jobs:
3136
# Linux builds (x64 and ARM64)
@@ -58,15 +63,11 @@ jobs:
5863

5964
- name: Configure version
6065
run: |
61-
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then
62-
echo "Setting version from workflow input: ${{ github.event.inputs.version }}"
63-
sed -i "s/VERSION [0-9.]\+/VERSION ${{ github.event.inputs.version }}/" src/auth/CMakeLists.txt
64-
else
65-
echo "Using version from CMakeLists.txt"
66-
fi
66+
# Use version from env variable (which comes from input or default)
67+
echo "Setting version to: ${{ env.LIB_VERSION }}"
68+
sed -i "s/VERSION [0-9.]\+/VERSION ${{ env.LIB_VERSION }}/" src/auth/CMakeLists.txt
6769
VERSION=$(grep "project(gopher-mcp-auth VERSION" src/auth/CMakeLists.txt | sed -n 's/.*VERSION \([0-9.]\+\).*/\1/p')
6870
echo "Building with version: $VERSION"
69-
echo "LIB_VERSION=$VERSION" >> $GITHUB_ENV
7071
7172
- name: Build library
7273
run: |
@@ -113,15 +114,11 @@ jobs:
113114

114115
- name: Configure version
115116
run: |
116-
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then
117-
echo "Setting version from workflow input: ${{ github.event.inputs.version }}"
118-
sed -i "s/VERSION [0-9.]\+/VERSION ${{ github.event.inputs.version }}/" src/auth/CMakeLists.txt
119-
else
120-
echo "Using version from CMakeLists.txt"
121-
fi
117+
# Use version from env variable (which comes from input or default)
118+
echo "Setting version to: ${{ env.LIB_VERSION }}"
119+
sed -i "s/VERSION [0-9.]\+/VERSION ${{ env.LIB_VERSION }}/" src/auth/CMakeLists.txt
122120
VERSION=$(grep "project(gopher-mcp-auth VERSION" src/auth/CMakeLists.txt | sed -n 's/.*VERSION \([0-9.]\+\).*/\1/p')
123121
echo "Building with version: $VERSION"
124-
echo "LIB_VERSION=$VERSION" >> $GITHUB_ENV
125122
126123
- name: Build library
127124
run: |
@@ -322,12 +319,13 @@ jobs:
322319
- name: Generate release tag
323320
id: tag
324321
run: |
325-
# Generate tag based on version and timestamp
322+
# Use the LIB_VERSION from the global env
326323
VERSION="${{ env.LIB_VERSION }}"
327324
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
328325
TAG="v${VERSION}-${TIMESTAMP}"
329326
echo "tag=${TAG}" >> $GITHUB_OUTPUT
330327
echo "Release tag: ${TAG}"
328+
echo "Version for release: ${VERSION}"
331329
332330
- name: Create GitHub Release
333331
uses: softprops/action-gh-release@v1

0 commit comments

Comments
 (0)