Files
skill-seekers-reference/.github/workflows/release.yml
yusyus 8f062bb96c Fix GitHub Actions release workflow permissions
Problem:
- Release workflow failing with "Resource not accessible by integration"
- Missing permissions for GITHUB_TOKEN to create releases
- Workflow tried to create releases that already exist manually

Fix:
1. Added `permissions: contents: write` at workflow level
   - Grants GITHUB_TOKEN permission to create/edit releases
   - Required for softprops/action-gh-release@v1

2. Added release existence check before creation
   - Prevents errors when release already exists
   - Skips creation gracefully with informative message
   - Useful for manually created releases (like v1.1.0)

Changes:
- Line 8-9: Added permissions section
- Line 48-57: Check if release exists with gh CLI
- Line 59-60: Only create if release doesn't exist
- Line 69-73: Skip message when release already exists

This allows:
- Automatic release creation on new tags
- Manual release creation without workflow conflicts
- Proper error handling and user feedback

Related: GitHub Actions permissions model
https://docs.github.com/en/actions/security-guides/automatic-token-authentication

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 23:13:55 +03:00

74 lines
2.0 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests beautifulsoup4
pip install pytest
if [ -f mcp/requirements.txt ]; then pip install -r mcp/requirements.txt; fi
- name: Run tests
run: |
python -m pytest tests/ -v
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create Release Notes
id: release_notes
run: |
if [ -f CHANGELOG.md ]; then
# Extract changelog for this version
sed -n "/## \[${{ steps.get_version.outputs.VERSION }}\]/,/## \[/p" CHANGELOG.md | sed '$d' > release_notes.md
else
echo "Release ${{ steps.get_version.outputs.VERSION }}" > release_notes.md
fi
- name: Check if release exists
id: check_release
run: |
if gh release view ${{ github.ref_name }} > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
if: steps.check_release.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
body_path: release_notes.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Skip Release Creation
if: steps.check_release.outputs.exists == 'true'
run: |
echo " Release ${{ github.ref_name }} already exists, skipping creation"
echo "View at: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}"