itchio-opengamepadui-plugin/.forgejo/workflows/build.yml

75 lines
2.7 KiB
YAML
Raw Normal View History

name: Build plugin
on:
push:
branches: [trunk]
tags: ["v*"]
pull_request:
branches: [trunk]
jobs:
build:
runs-on: [docker, ubuntu-24.04]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get update
apt-get install -y -qq make git wget
- name: Install Godot
run: |
wget -q https://github.com/godotengine/godot/releases/download/4.4.1-stable/Godot_v4.4.1-stable_linux.x86_64.zip
# python3 instead of unzip: the runner's apt index goes stale and the
# pinned unzip deb 404s in the security pool.
python3 -m zipfile -e Godot_v4.4.1-stable_linux.x86_64.zip godot-dir
mkdir -p "$HOME/.local/bin"
mv godot-dir/Godot_v4.4.1-stable_linux.x86_64 "$HOME/.local/bin/godot"
chmod +x "$HOME/.local/bin/godot"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Build
env:
GODOT: godot
run: make dist
- name: Create release
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
# Create the release. `curl -sf` hid the reason a tag build could not
# publish, which left devices on the previous release with no clue,
# so report the status code and the API answer.
HTTP=$(curl -sS -o /tmp/release.json -w "%{http_code}" -X POST "${API}/releases" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\"}")
if [ "${HTTP}" != "201" ] && [ "${HTTP}" != "200" ]; then
echo "Release creation for ${TAG} failed with HTTP ${HTTP}:"
cat /tmp/release.json
exit 1
fi
RELEASE_ID=$(python3 -c "import json; print(json.load(open('/tmp/release.json'))['id'])")
# Upload assets
for FILE in dist/itch.zip dist/itch.zip.sha256.txt; do
NAME=$(basename "$FILE")
HTTP=$(curl -sS -o /tmp/asset.json -w "%{http_code}" -X POST \
"${API}/releases/${RELEASE_ID}/assets?name=${NAME}" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@${FILE}")
if [ "${HTTP}" != "201" ] && [ "${HTTP}" != "200" ]; then
echo "Asset upload of ${NAME} failed with HTTP ${HTTP}:"
cat /tmp/asset.json
exit 1
fi
done