Files
rudi 8b11f14a4a
Build and Test j3270 / Build JAR & Run Tests (push) Successful in 41s
Release j3270 / Build & Publish Release (push) Successful in 1m2s
Add more stuff
2026-08-20 19:25:14 -04:00

93 lines
3.1 KiB
YAML

name: Release j3270
on:
push:
tags:
- 'v*'
jobs:
release:
name: Build & Publish Release
runs-on: ubuntu-latest
steps:
- name: Configure Dynamic DNS Resolvers
run: |
printf "nameserver 1.1.1.1\nnameserver 8.8.8.8\n" > /etc/resolv.conf 2>/dev/null || true
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Java JDK (Temurin 17)
uses: actions/setup-java@v3
continue-on-error: true
with:
java-version: '17'
distribution: 'temurin'
- name: Ensure Java Available
run: |
if ! command -v javac >/dev/null 2>&1; then
echo "Installing OpenJDK 17 via package manager..."
if command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y openjdk-17-jdk-headless || true
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache openjdk17 || true
fi
fi
echo "Java compiler:"
javac -version || which javac || true
echo "Java runtime:"
java -version || which java || true
- name: Make scripts executable
run: |
chmod +x ./build_all.sh ./test_all.sh ./run.sh
- name: Build & Run Unit Tests
run: |
sh ./test_all.sh
- name: Upload Release Artifact
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: j3270-${{ github.ref_name }}
path: build/j3270.jar
- name: Publish Release to Gitea
continue-on-error: true
run: |
TAG="${{ github.ref_name }}"
API_URL="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
TOKEN="${{ secrets.GITHUB_TOKEN }}"
IS_PRERELEASE="false"
case "$TAG" in
*beta*|*alpha*|*rc*|*pre*|*preview*|*dev*)
IS_PRERELEASE="true"
echo "Tag $TAG detected as pre-release / beta."
;;
esac
echo "Creating Release for tag $TAG (prerelease=$IS_PRERELEASE)..."
RESPONSE=$(curl -s -X POST "$API_URL" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"$TAG\", \"name\": \"j3270 $TAG\", \"body\": \"Automated release for **$TAG**.\n\n### Running j3270\n```bash\njava -jar j3270.jar\n```\", \"draft\": false, \"prerelease\": $IS_PRERELEASE}")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -n 1 | cut -d':' -f2)
if [ -n "$RELEASE_ID" ]; then
echo "Uploading build/j3270.jar to release $RELEASE_ID..."
curl -s -X POST "$API_URL/$RELEASE_ID/assets?name=j3270.jar" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/java-archive" \
--data-binary @"build/j3270.jar"
echo "Release $TAG published with j3270.jar attached successfully!"
else
echo "Release API response: $RESPONSE"
fi