From 5fb117340a675ffefe02714017549b6358d4bbc4 Mon Sep 17 00:00:00 2001 From: dave <market_madi1@protonmail.com> Date: Fri, 4 Apr 2025 16:06:00 +0300 Subject: [PATCH] fix: pipeline version v6 --- .gitea/workflows/zapstore-manual.yaml | 89 ++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/zapstore-manual.yaml b/.gitea/workflows/zapstore-manual.yaml index 87c1cd4..e9eaf8c 100644 --- a/.gitea/workflows/zapstore-manual.yaml +++ b/.gitea/workflows/zapstore-manual.yaml @@ -26,6 +26,22 @@ jobs: VERSION="0.1.1" echo "VERSION=$VERSION" >> $GITHUB_ENV echo "Publishing version: $VERSION" + + - name: Create and push Git tag + run: | + # Configure Git credentials + git config --global user.name "Gitea Actions" + git config --global user.email "actions@gitea.com" + + # Create tag if it doesn't exist + if ! git tag | grep -q "v${VERSION}"; then + echo "Creating tag v${VERSION}..." + git tag -a "v${VERSION}" -m "Release version ${VERSION}" + git push origin "v${VERSION}" + echo "✅ Tag v${VERSION} created and pushed" + else + echo "✅ Tag v${VERSION} already exists" + fi - name: Prepare release directory run: mkdir -p ./release @@ -184,4 +200,75 @@ jobs: if: ${{ success() }} run: | echo "🎉 Voca ${VERSION} published to Zapstore!" - echo "🔗 https://zapstore.dev/app/voca" \ No newline at end of file + echo "🔗 https://zapstore.dev/app/voca" + + - name: Create Gitea Release + run: | + # Ensure tag exists + echo "Creating Gitea release for tag v${VERSION}..." + + # Extract release notes from CHANGELOG.md or create default notes + RELEASE_NOTES="Automated release for v${VERSION}. See CHANGELOG.md for details." + if [ -f "CHANGELOG.md" ]; then + echo "Extracting release notes from CHANGELOG.md..." + # Try to extract relevant section for this version + VERSION_NOTES=$(sed -n "/## v${VERSION}/,/## v/p" CHANGELOG.md | sed '/## v[0-9]/d') + if [ ! -z "$VERSION_NOTES" ]; then + RELEASE_NOTES="$VERSION_NOTES" + fi + fi + + echo "Using release notes: $RELEASE_NOTES" + + # Create JSON payload for release creation + PAYLOAD=$(cat <<EOF + { + "tag_name": "v${VERSION}", + "name": "v${VERSION}", + "body": "$RELEASE_NOTES", + "draft": false, + "prerelease": false + } + EOF + ) + + # Create the release via Gitea API + REPO_OWNER="voca" + REPO_NAME="voca" + API_URL="https://git.nostrdev.com/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases" + + HTTP_RESPONSE=$(curl -s -w "%{http_code}" \ + -X POST "$API_URL" \ + -H "accept: application/json" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -d "$PAYLOAD") + + HTTP_BODY=${HTTP_RESPONSE:0:${#HTTP_RESPONSE}-3} + HTTP_STATUS=${HTTP_RESPONSE:${#HTTP_RESPONSE}-3} + + if [ "$HTTP_STATUS" = "201" ] || [ "$HTTP_STATUS" = "200" ]; then + echo "✅ Gitea release created successfully!" + # Extract release ID for uploading assets + RELEASE_ID=$(echo "$HTTP_BODY" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) + + # Upload APK as release asset + APK_NAME="voca-${VERSION}.apk" + if [ -f "./release/${APK_NAME}" ]; then + echo "Uploading APK to release..." + UPLOAD_URL="https://git.nostrdev.com/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets" + + curl -X POST "$UPLOAD_URL" \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "Content-Type: application/octet-stream" \ + -F "attachment=@./release/${APK_NAME}" \ + -F "name=${APK_NAME}" + + echo "✅ APK uploaded to Gitea release" + else + echo "❌ APK file not found for upload" + fi + else + echo "❌ Failed to create Gitea release. Status: $HTTP_STATUS, Response: $HTTP_BODY" + echo "API URL: $API_URL" + fi \ No newline at end of file