Watch
1
0
Fork
You've already forked SouveraineOS
0
SouveraineOS/.gitea/workflows/distribution.yml
2026-08-25 08:07:07 -04:00

68 lines
2.5 KiB
YAML

name: distribution-contract
on:
push:
branches: [main, public]
pull_request:
branches: [main, public]
workflow_dispatch:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Validate the release and installer graph
run: python3 tools/validate-distribution.py distribution/manifest.toml
# The projection. Gitea is the only thing that publishes.
sync-public:
runs-on: ubuntu-latest
needs: [validate]
if: github.ref == 'refs/heads/public'
env:
PUBLIC_FORGE_TOKEN: ${{ secrets.PUBLIC_FORGE_TOKEN }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Publish and verify exact SHA
run: |
set -euo pipefail
: "${PUBLIC_FORGE_TOKEN:?PUBLIC_FORGE_TOKEN is required}"
expected="${GITHUB_SHA}"
forge_url='https://forge.caseytunturi.com/Fimeg/SouveraineOS.git'
remote_sha=''
for attempt in 1 2 3; do
if remote_sha="$(git ls-remote "$forge_url" refs/heads/public | awk '{print $1}')"; then
break
fi
test "$attempt" -lt 3 || exit 1
sleep $((attempt * 10))
done
if [ -n "$remote_sha" ]; then
git cat-file -e "${remote_sha}^{commit}" 2>/dev/null || {
echo "[publish] remote public SHA is not in tested history" >&2; exit 1; }
git merge-base --is-ancestor "$remote_sha" "$expected" || {
echo "[publish] refusing non-fast-forward public history" >&2; exit 1; }
fi
auth="$(printf 'publisher-souveraineos:%s' "$PUBLIC_FORGE_TOKEN" | base64 -w0)"
for attempt in 1 2 3; do
if git -c "http.https://forge.caseytunturi.com/.extraheader=Authorization: Basic $auth" \
push "$forge_url" public:public; then
break
fi
test "$attempt" -lt 3 || exit 1
sleep $((attempt * 10))
done
observed=''
for attempt in 1 2 3; do
if observed="$(git ls-remote "$forge_url" refs/heads/public | awk '{print $1}')"; then
test "$observed" = "$expected"
break
fi
test "$attempt" -lt 3 || exit 1
sleep $((attempt * 10))
done
test "$observed" = "$expected"
echo "[publish] exact SHA is anonymous on Forgejo: $expected"