fix: replace unsupported artifact actions with direct release uploads
All checks were successful
Build and Release / Lint and Test (push) Successful in 7m57s
Build and Release / Build Binaries (amd64, windows) (push) Successful in 1m15s
Build and Release / Build Binaries (arm64, darwin) (push) Successful in 1m21s
Build and Release / Build Binaries (amd64, darwin) (push) Successful in 3m26s
Build and Release / Build Binaries (arm64, linux) (push) Successful in 1m6s
Build and Release / Build Binaries (amd64, linux) (push) Successful in 2m58s
All checks were successful
Build and Release / Lint and Test (push) Successful in 7m57s
Build and Release / Build Binaries (amd64, windows) (push) Successful in 1m15s
Build and Release / Build Binaries (arm64, darwin) (push) Successful in 1m21s
Build and Release / Build Binaries (amd64, darwin) (push) Successful in 3m26s
Build and Release / Build Binaries (arm64, linux) (push) Successful in 1m6s
Build and Release / Build Binaries (amd64, linux) (push) Successful in 2m58s
- Remove actions/upload-artifact@v4 (not supported on Gitea Actions) - Remove actions/download-artifact@v4 (not supported on Gitea Actions) - Remove separate release job (no longer needed) - Remove disabled Docker job - Each build matrix job now uploads directly to release via Gitea API - Adds delete-existing-asset logic before uploading 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f23347a26e
commit
1ad0368230
@ -184,152 +184,49 @@ jobs:
|
|||||||
# Create checksum
|
# Create checksum
|
||||||
cd dist && sha256sum "${OUTPUT}" > "${OUTPUT}.sha256"
|
cd dist && sha256sum "${OUTPUT}" > "${OUTPUT}.sha256"
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload to release
|
||||||
uses: actions/upload-artifact@v4
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
with:
|
|
||||||
name: gitea-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
||||||
path: dist/gitea-*
|
|
||||||
retention-days: 7
|
|
||||||
|
|
||||||
# Docker build job - disabled until Docker is available on runner
|
|
||||||
docker:
|
|
||||||
name: Build Docker Image
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: lint-test
|
|
||||||
if: false # Disabled - runner doesn't have Docker
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Get version
|
|
||||||
id: version
|
|
||||||
run: |
|
run: |
|
||||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
VERSION=$(git describe --tags --always 2>/dev/null || echo "dev")
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
echo "Uploading binaries for $VERSION"
|
||||||
else
|
|
||||||
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
|
||||||
fi
|
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Build Docker image
|
# Get or create release
|
||||||
uses: docker/build-push-action@v5
|
TAG="${{ github.ref_name }}"
|
||||||
with:
|
EXISTING=$(curl -s \
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: false
|
|
||||||
tags: |
|
|
||||||
gitea/gitea:${{ steps.version.outputs.version }}
|
|
||||||
gitea/gitea:latest
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
# Release job - only runs on tags
|
|
||||||
release:
|
|
||||||
name: Create Release
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Download all artifacts
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
path: dist
|
|
||||||
merge-multiple: true
|
|
||||||
|
|
||||||
- name: List artifacts
|
|
||||||
run: ls -la dist/
|
|
||||||
|
|
||||||
- name: Get version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Generate changelog
|
|
||||||
id: changelog
|
|
||||||
run: |
|
|
||||||
# Get commits since last tag
|
|
||||||
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
||||||
if [ -n "$PREV_TAG" ]; then
|
|
||||||
CHANGELOG=$(git log --pretty=format:"- %s (%h)" ${PREV_TAG}..HEAD)
|
|
||||||
else
|
|
||||||
CHANGELOG=$(git log --pretty=format:"- %s (%h)" -20)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Escape for GitHub Actions
|
|
||||||
CHANGELOG="${CHANGELOG//'%'/'%25'}"
|
|
||||||
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
|
|
||||||
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
|
|
||||||
|
|
||||||
echo "changelog=${CHANGELOG}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.version.outputs.version }}"
|
|
||||||
IS_PRERELEASE="false"
|
|
||||||
if [[ "$VERSION" == *"-rc"* ]] || [[ "$VERSION" == *"-beta"* ]] || [[ "$VERSION" == *"-alpha"* ]]; then
|
|
||||||
IS_PRERELEASE="true"
|
|
||||||
fi
|
|
||||||
|
|
||||||
RELEASE_BODY="## Changes in ${VERSION}
|
|
||||||
|
|
||||||
${{ steps.changelog.outputs.changelog }}
|
|
||||||
|
|
||||||
## Downloads
|
|
||||||
|
|
||||||
| Platform | Architecture | Download |
|
|
||||||
|----------|--------------|----------|
|
|
||||||
| Linux | amd64 | gitea-${VERSION}-linux-amd64 |
|
|
||||||
| Linux | arm64 | gitea-${VERSION}-linux-arm64 |
|
|
||||||
| macOS | amd64 | gitea-${VERSION}-darwin-amd64 |
|
|
||||||
| macOS | arm64 | gitea-${VERSION}-darwin-arm64 |
|
|
||||||
| Windows | amd64 | gitea-${VERSION}-windows-amd64.exe |
|
|
||||||
|
|
||||||
## Checksums
|
|
||||||
|
|
||||||
SHA256 checksums are provided in .sha256 files alongside each binary."
|
|
||||||
|
|
||||||
# Create release via Gitea API
|
|
||||||
RELEASE_DATA=$(jq -n \
|
|
||||||
--arg tag "$VERSION" \
|
|
||||||
--arg name "Gitea $VERSION" \
|
|
||||||
--arg body "$RELEASE_BODY" \
|
|
||||||
--argjson prerelease "$IS_PRERELEASE" \
|
|
||||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: $prerelease}')
|
|
||||||
|
|
||||||
RESPONSE=$(curl -s -X POST \
|
|
||||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/$TAG")
|
||||||
-d "$RELEASE_DATA" \
|
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")
|
|
||||||
|
|
||||||
echo "Release response: $RESPONSE"
|
if echo "$EXISTING" | grep -q '"id":[0-9]'; then
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
RELEASE_ID=$(echo "$EXISTING" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
echo "Created release with ID: $RELEASE_ID"
|
echo "Found existing release: $RELEASE_ID"
|
||||||
|
else
|
||||||
|
echo "Creating release..."
|
||||||
|
RESPONSE=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"tag_name":"'"$TAG"'","name":"Gitea '"$TAG"'","body":"Official release.","draft":false,"prerelease":false}' \
|
||||||
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases")
|
||||||
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||||
|
echo "Created release: $RELEASE_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
# Upload assets
|
# Upload files
|
||||||
for file in dist/*; do
|
for file in dist/*; do
|
||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
filename=$(basename "$file")
|
filename=$(basename "$file")
|
||||||
|
# Delete existing asset if present
|
||||||
|
ASSETS=$(curl -s -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||||
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID")
|
||||||
|
ASSET_ID=$(echo "$ASSETS" | grep -o "\"id\":[0-9]*,\"name\":\"$filename\"" | grep -o '"id":[0-9]*' | cut -d: -f2)
|
||||||
|
if [ -n "$ASSET_ID" ]; then
|
||||||
|
echo "Deleting existing $filename"
|
||||||
|
curl -s -X DELETE -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||||
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets/$ASSET_ID"
|
||||||
|
fi
|
||||||
echo "Uploading $filename..."
|
echo "Uploading $filename..."
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||||
-H "Content-Type: multipart/form-data" \
|
|
||||||
-F "attachment=@$file" \
|
-F "attachment=@$file" \
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$filename"
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$filename"
|
||||||
echo "Uploaded $filename"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user