feat: use flutter-action and forgejo-release actions in CI workflows #5

Merged
fmartingr merged 3 commits from ci/forgejo-actions into master 2026-04-07 12:56:11 +02:00
4 changed files with 33 additions and 113 deletions

View file

@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -eux
apt-get update -qq && apt-get install -y --no-install-recommends bash curl git unzip xz-utils ca-certificates > /dev/null
git config --global --add safe.directory '*'
curl -fsSL -o /tmp/flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.41.0-stable.tar.xz
tar xf /tmp/flutter.tar.xz -C /opt && rm /tmp/flutter.tar.xz
export PATH="/opt/flutter/bin:/opt/flutter/bin/cache/dart-sdk/bin:$PATH"
flutter pub get
dart format --set-exit-if-changed .
flutter pub run build_runner build --delete-conflicting-outputs
flutter analyze

View file

@ -7,7 +7,17 @@ jobs:
lint:
runs-on: docker
container:
image: debian:bookworm-slim
image: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- run: bash .forgejo/scripts/pr-lint.sh
- uses: actions/checkout@v6
- name: Install Flutter
uses: actions/flutter-action@v2
with:
channel: stable
- name: Lint
run: |
git config --global --add safe.directory '*'
flutter pub get
dart format --set-exit-if-changed .
flutter pub run build_runner build --delete-conflicting-outputs
flutter analyze

View file

@ -9,13 +9,18 @@ jobs:
build:
runs-on: docker
container:
image: ghcr.io/cirruslabs/flutter:stable
image: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Install Flutter
uses: actions/flutter-action@v2
with:
channel: stable
- name: Set up release signing
env:
SIGNING_KEYSTORE: ${{ secrets.SIGNING_KEYSTORE }}
@ -48,11 +53,17 @@ jobs:
CI_FORGE_URL: ${{ github.server_url }}
CI_REPO: ${{ github.repository }}
- name: Create release
- name: Prepare release assets
run: |
bash scripts/create-release.sh "${{ github.ref_name }}" "worldhopper-${{ github.ref_name }}.apk" CHANGELOG.md
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
CI_FORGE_URL: ${{ github.server_url }}
CI_REPO_OWNER: ${{ github.repository_owner }}
CI_REPO_NAME: ${{ github.event.repository.name }}
mkdir -p dist/release
cp worldhopper-${{ github.ref_name }}.apk dist/release/
- name: Create release
uses: actions/forgejo-release@v2
with:
direction: upload
token: ${{ secrets.FORGEJO_TOKEN }}
tag: ${{ github.ref_name }}
release-dir: dist/release
release-notes-file: CHANGELOG.md
prerelease: ${{ contains(github.ref_name, '-rc.') }}

View file

@ -1,87 +0,0 @@
#!/bin/sh
# Create a Forgejo release using tea CLI
# Used by CI to publish releases with changelog and assets
#
# Usage: ./create-release.sh <tag> <apk-file> <changelog-file>
# 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 <tag> <apk-file> <changelog-file>"
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
# Detect pre-release tags (e.g., v1.0.0-rc.1)
PRERELEASE_FLAG=""
case "$TAG" in
*-rc.*) PRERELEASE_FLAG="--prerelease" ;;
esac
# 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}" \
$PRERELEASE_FLAG
echo ""
echo "✅ Release created successfully!"
echo " View at: ${CI_FORGE_URL}/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases/tag/${TAG}"