ci: use gitea.* context variables in Forgejo release workflow
Some checks failed
release / Build (darwin/amd64) (push) Failing after 0s
release / Build (linux/amd64) (push) Failing after 0s
release / Build (windows/amd64) (push) Failing after 0s
release / Build (darwin/arm64) (push) Failing after 0s
release / Build (linux/arm64) (push) Failing after 0s
release / Build (windows/arm64) (push) Failing after 0s
release / Publish release (push) Has been skipped
Some checks failed
release / Build (darwin/amd64) (push) Failing after 0s
release / Build (linux/amd64) (push) Failing after 0s
release / Build (windows/amd64) (push) Failing after 0s
release / Build (darwin/arm64) (push) Failing after 0s
release / Build (linux/arm64) (push) Failing after 0s
release / Build (windows/arm64) (push) Failing after 0s
release / Publish release (push) Has been skipped
This commit is contained in:
parent
9fc0562ace
commit
280c8789f6
1 changed files with 43 additions and 9 deletions
|
|
@ -49,7 +49,7 @@ jobs:
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build binary
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ github.ref_name }}
|
VERSION: ${{ gitea.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
|
@ -93,11 +93,45 @@ jobs:
|
||||||
sha256sum * > SHA256SUMS
|
sha256sum * > SHA256SUMS
|
||||||
ls -lh
|
ls -lh
|
||||||
|
|
||||||
- name: Create Forgejo release
|
- name: Create Forgejo release and upload assets
|
||||||
uses: https://github.com/softprops/action-gh-release@v2
|
env:
|
||||||
with:
|
TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
name: ${{ github.ref_name }}
|
TAG: ${{ gitea.ref_name }}
|
||||||
prerelease: ${{ contains(github.ref_name, '-') }}
|
API_URL: ${{ gitea.api_url }}
|
||||||
generate_release_notes: true
|
REPO: ${{ gitea.repository }}
|
||||||
files: |
|
run: |
|
||||||
release/*
|
set -euo pipefail
|
||||||
|
IS_PRERELEASE="false"
|
||||||
|
if [[ "$TAG" == *-* ]]; then
|
||||||
|
IS_PRERELEASE="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating Release $TAG in Forgejo ($REPO)..."
|
||||||
|
RESPONSE=$(curl -sS -X POST \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"prerelease\":$IS_PRERELEASE}" \
|
||||||
|
"$API_URL/repos/$REPO/releases")
|
||||||
|
|
||||||
|
RELEASE_ID=$(echo "$RESPONSE" | jq -r ".id" 2>/dev/null || echo "$RESPONSE" | grep -o '"id":[^,]*' | head -n 1 | cut -d':' -f2 | tr -d ' ')
|
||||||
|
|
||||||
|
if [[ -z "$RELEASE_ID" || "$RELEASE_ID" == "null" ]]; then
|
||||||
|
echo "Error creating release in Forgejo. Response:"
|
||||||
|
echo "$RESPONSE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release created successfully in Forgejo with ID: $RELEASE_ID"
|
||||||
|
|
||||||
|
for FILE in release/*; do
|
||||||
|
if [ -f "$FILE" ]; then
|
||||||
|
FILENAME=$(basename "$FILE")
|
||||||
|
echo "Uploading $FILENAME to Forgejo release $RELEASE_ID..."
|
||||||
|
curl -sS -X POST \
|
||||||
|
-H "Authorization: token $TOKEN" \
|
||||||
|
-F "attachment=@$FILE" \
|
||||||
|
"$API_URL/repos/$REPO/releases/$RELEASE_ID/assets"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "All assets uploaded successfully to Forgejo Release!"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue