#!/bin/sh # Create a Forgejo release using tea CLI # Used by Woodpecker CI to publish releases with changelog and assets # # Usage: ./create-release.sh # tag: Git tag for the release (e.g., v1.0.0) # apk-file: Path to APK file to attach # changelog-file: Path to changelog file to use as release notes # # Required Environment Variables: # FORGEJO_TOKEN: Personal access token with repo permissions # CI_FORGE_URL: Base URL of Forgejo instance (e.g., https://forgejo.example.com) # CI_REPO_OWNER: Repository owner/organization # CI_REPO_NAME: Repository name set -e # Check required arguments if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then echo "Error: Missing required arguments" echo "Usage: $0 " exit 1 fi TAG="$1" APK_FILE="$2" CHANGELOG_FILE="$3" # Check required environment variables if [ -z "$FORGEJO_TOKEN" ]; then echo "Error: FORGEJO_TOKEN environment variable is required" exit 1 fi if [ -z "$CI_FORGE_URL" ]; then echo "Error: CI_FORGE_URL environment variable is required" exit 1 fi if [ -z "$CI_REPO_OWNER" ] || [ -z "$CI_REPO_NAME" ]; then echo "Error: CI_REPO_OWNER and CI_REPO_NAME environment variables are required" exit 1 fi # Check that files exist if [ ! -f "$APK_FILE" ]; then echo "Error: APK file not found: $APK_FILE" exit 1 fi if [ ! -f "$CHANGELOG_FILE" ]; then echo "Error: Changelog file not found: $CHANGELOG_FILE" exit 1 fi echo "Creating Forgejo release for ${TAG}..." echo " Repository: ${CI_REPO_OWNER}/${CI_REPO_NAME}" echo " Forge URL: ${CI_FORGE_URL}" echo " APK: ${APK_FILE}" echo " Changelog: ${CHANGELOG_FILE}" # Configure tea with Forgejo credentials echo "Configuring tea CLI..." tea login add \ --url "${CI_FORGE_URL}" \ --token "${FORGEJO_TOKEN}" \ --name ci # Create release with changelog and APK attachment echo "Creating release..." tea release create \ --repo "${CI_REPO_OWNER}/${CI_REPO_NAME}" \ --tag "${TAG}" \ --title "Worldhopper ${TAG}" \ --note "$(cat "${CHANGELOG_FILE}")" \ --asset "${APK_FILE}" echo "" echo "✅ Release created successfully!" echo " View at: ${CI_FORGE_URL}/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases/tag/${TAG}"