Skip to content

Release Ephemeris Data Files #39

Release Ephemeris Data Files

Release Ephemeris Data Files #39

name: Release Ephemeris Data Files
on:
schedule:
- cron: '0 0 * * *' # Daily at midnight UTC
workflow_dispatch:
repository_dispatch:
types:
- check_update
concurrency:
group: release-ephe-files
cancel-in-progress: false
permissions:
contents: write
jobs:
check-and-release:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch latest ephe commit info from upstream
id: upstream
run: |
set -euo pipefail
RESPONSE=$(curl -fsSL \
"https://api.github.com/repos/aloistr/swisseph/commits?path=ephe&per_page=1")
HASH=$(echo "$RESPONSE" | python3 -c "import sys, json; commits = json.load(sys.stdin); print(commits[0]['sha'] if commits else '')")
DATE=$(echo "$RESPONSE" | python3 -c "import sys, json; commits = json.load(sys.stdin); print(commits[0]['commit']['committer']['date'][:10] if commits else '')")
if [ -z "$HASH" ] || [ -z "$DATE" ]; then
echo "Failed to fetch upstream ephe commit info"
exit 1
fi
echo "hash=$HASH" >> "$GITHUB_OUTPUT"
echo "date=$DATE" >> "$GITHUB_OUTPUT"
echo "Upstream hash: $HASH"
echo "Upstream date: $DATE"
- name: Get current release commit hash (if exists)
id: current
run: |
set -euo pipefail
if gh release view ephe-files &>/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
NOTES=$(gh release view ephe-files --json body -q '.body' || true)
CURRENT_HASH=$(echo "$NOTES" | grep -oP '(?<=\*\*Upstream Commit:\*\* `)[^`]+' || true)
echo "current_hash=$CURRENT_HASH" >> "$GITHUB_OUTPUT"
echo "Current release hash: $CURRENT_HASH"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "current_hash=" >> "$GITHUB_OUTPUT"
echo "No existing release found"
fi
- name: Skip if upstream is unchanged
if: steps.current.outputs.current_hash == steps.upstream.outputs.hash
run: |
echo "No upstream ephe changes detected. Skipping release."
- name: Download ephemeris files from upstream
if: steps.current.outputs.current_hash != steps.upstream.outputs.hash
run: |
set -euo pipefail
rm -rf ephe-temp swisseph-temp ephe-files.tar.gz ephe-files.zip ephe-files-full.tar.gz ephe-files-full.zip
mkdir -p swisseph-temp ephe-temp
echo "Downloading upstream repository..."
curl -fsSL "https://github.com/aloistr/swisseph/archive/refs/heads/master.tar.gz" | tar -xzf - -C swisseph-temp
echo "Copying ephe folder..."
cp -r swisseph-temp/swisseph-master/ephe/. ephe-temp/
echo "Files downloaded:"
ls -la ephe-temp
- name: Create archives
if: steps.current.outputs.current_hash != steps.upstream.outputs.hash
run: |
set -euo pipefail
cd ephe-temp
tar -czf ../ephe-files.tar.gz sepl*.se1 semo*.se1
zip -q ../ephe-files.zip sepl*.se1 semo*.se1
tar -czf ../ephe-files-full.tar.gz .
zip -q -r ../ephe-files-full.zip .
cd ..
echo "Archive sizes:"
ls -lh *.tar.gz *.zip
- name: Delete old release assets and release
if: steps.current.outputs.exists == 'true' && steps.current.outputs.current_hash != steps.upstream.outputs.hash
run: |
set -euo pipefail
echo "Deleting old release assets..."
for asset in $(gh release view ephe-files --json assets -q '.assets[].name' 2>/dev/null || true); do
gh release delete-asset ephe-files "$asset" --yes || true
done
echo "Deleting old release..."
gh release delete ephe-files --yes || true
- name: Create GitHub Release
if: steps.current.outputs.current_hash != steps.upstream.outputs.hash
run: |
set -euo pipefail
NOTES=$(cat << 'NOTES_EOF'
Updated ephemeris data files from upstream.
**Date:** ${{ steps.upstream.outputs.date }}
**Upstream Commit:** `${{ steps.upstream.outputs.hash }}`
These files are licensed under **AGPL-3.0**.
Source: https://github.com/aloistr/swisseph
> **Trust Note:** These archives are mirrored for convenience only.
> I do not modify the upstream ephemeris files.
---
**Files included in ephe-files.tar.gz / ephe-files.zip**
- `sepl*.se1` - Planet ephemeris files
- `semo*.se1` - Moon ephemeris file
**Files included in ephe-files-full.tar.gz / ephe-files-full.zip**
- All files from the upstream `ephe/` folder
NOTES_EOF
)
gh release create ephe-files \
ephe-files.tar.gz \
ephe-files.zip \
ephe-files-full.tar.gz \
ephe-files-full.zip \
--title "Ephemeris Data Files (${{ steps.upstream.outputs.date }})" \
--notes "$NOTES"
- name: Summary
run: |
echo ""
echo "Workflow finished"
echo "Upstream date: ${{ steps.upstream.outputs.date }}"
echo "Upstream commit: ${{ steps.upstream.outputs.hash }}"
echo ""
echo "Release URL:"
echo "https://github.com/jayeshmepani/Swiss-Ephemeris-PHP/releases/tag/ephe-files"