83 lines
2.5 KiB
YAML
83 lines
2.5 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
# Midnight UTC every day (Actions cron is UTC). For local midnight, shift hours, e.g. 22:00 UTC ≈ midnight CET (winter).
|
|
- cron: "0 0 * * *"
|
|
|
|
concurrency:
|
|
group: nightly-release-${{ github.repository }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build-and-release:
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
# Clone from Gitea (this runner cannot reach github.com for actions/checkout@v4)
|
|
- name: Checkout repository
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
cd "${GITHUB_WORKSPACE}"
|
|
SERVER="${{ github.server_url }}"
|
|
REPO="${{ github.repository }}"
|
|
SHA="${{ github.sha }}"
|
|
HOST="${SERVER#*://}"
|
|
HOST="${HOST%%/*}"
|
|
if [ -n "${GITHUB_TOKEN:-}" ]; then
|
|
URL="https://oauth2:${GITHUB_TOKEN}@${HOST}/${REPO}.git"
|
|
else
|
|
URL="${SERVER}/${REPO}.git"
|
|
fi
|
|
git init
|
|
git remote add origin "$URL"
|
|
git fetch --depth 1 origin "$SHA"
|
|
git checkout --force FETCH_HEAD
|
|
|
|
- name: Set up build tools
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y zip rsync
|
|
|
|
- name: Build zip package
|
|
run: make zip
|
|
|
|
- name: Nightly release (single tag, updated in place)
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
TAG=nightly
|
|
ZIP="./output/OmniNX Downloader.zip"
|
|
REPO="${{ github.repository }}"
|
|
SHA="${{ github.sha }}"
|
|
REF="${{ github.ref_name }}"
|
|
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git tag -f "$TAG"
|
|
git push origin "refs/tags/$TAG" --force
|
|
|
|
NOTES="Single nightly build artifact (updated every push).
|
|
|
|
**Commit:** \`${SHA}\`
|
|
**Branch:** \`${REF}\`
|
|
**Built:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
|
|
|
|
if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
|
|
gh release upload "$TAG" "$ZIP" --clobber --repo "$REPO"
|
|
gh release edit "$TAG" --title "Nightly" --notes "$NOTES" --prerelease --repo "$REPO"
|
|
else
|
|
gh release create "$TAG" "$ZIP" \
|
|
--title "Nightly" \
|
|
--notes "$NOTES" \
|
|
--prerelease \
|
|
--repo "$REPO"
|
|
fi
|