Files
terraria-server-manager/.gitea/workflows/release.yaml
T
abrown38 208c81899a
release / deb (push) Successful in 14s
debian repo
2026-09-30 20:01:10 +00:00

67 lines
2.5 KiB
YAML

# Builds the .deb when a version tag is pushed and publishes it as a release,
# with that version's CHANGELOG.md section as the release notes. To release,
# set VERSION and CHANGELOG.md, commit, then:
# git tag v$(cat VERSION) && git push origin v$(cat VERSION)
name: release
on:
push:
tags: ['v*']
jobs:
deb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check that the tag matches VERSION
run: |
if [ "$GITHUB_REF_NAME" != "v$(cat VERSION)" ]; then
echo "tag $GITHUB_REF_NAME doesn't match VERSION ($(cat VERSION))"
exit 1
fi
- name: Install build tools
env:
DEBIAN_FRONTEND: noninteractive
run: |
SUDO=$(command -v sudo || true)
$SUDO apt-get update -qq
$SUDO apt-get install -y -qq make python3 dpkg curl shellcheck python3-pyflakes
- name: Build (make check runs first)
run: make deb
- name: Publish the release
env:
GITEA_URL: ${{ gitea.server_url }}
GITEA_REPO: ${{ gitea.repository }}
# The job's own token; set a RELEASE_TOKEN secret instead if it isn't allowed to write releases
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITEA_TOKEN }}
run: python3 packaging/gitea-release.py "$GITHUB_REF_NAME" build/*.deb
# Gitea's Debian registry, as an apt repository:
# deb <server>/api/packages/<owner>/debian stable main
- name: Publish to the apt repository
env:
POOL: ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/debian/pool/stable/main
# The job's own token; set a PACKAGE_TOKEN secret (scope write:package) if it isn't allowed to
TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.GITEA_TOKEN }}
run: |
deb=$(echo build/*.deb)
upload() {
curl -sS -o response.txt -w '%{http_code}' --user "$GITHUB_ACTOR:$TOKEN" \
--upload-file "$deb" "$POOL/upload"
}
status=$(upload)
if [ "$status" = 409 ]; then
# This version is there already (the tag was pushed again): replace it
curl -sS -f --user "$GITHUB_ACTOR:$TOKEN" -X DELETE \
"$POOL/terraria-server-manager/$(cat VERSION)/all"
status=$(upload)
fi
if [ "$status" != 201 ]; then
echo "upload failed: HTTP $status"; cat response.txt; echo; exit 1
fi
echo "published $(basename "$deb") to $POOL"