forked from heavy-duty/stoke
57 lines
2.2 KiB
YAML
57 lines
2.2 KiB
YAML
|
|
# Release automation: on every v* tag, build the Debian package, publish it
|
||
|
|
# to the Forgejo Debian registry (owner: heavy-duty) and attach the .deb to
|
||
|
|
# the tag's release page as a fallback for direct `dpkg -i` installs.
|
||
|
|
#
|
||
|
|
# Requirements:
|
||
|
|
# - A Forgejo Actions runner on the instance. Adjust `runs-on` to a label
|
||
|
|
# your runner actually advertises (common: docker, ubuntu-latest).
|
||
|
|
# - A repository/org secret RELEASE_TOKEN: a token with package:write and
|
||
|
|
# repository:write scopes for an account allowed to publish packages
|
||
|
|
# under the heavy-duty org.
|
||
|
|
|
||
|
|
name: release
|
||
|
|
on:
|
||
|
|
push:
|
||
|
|
tags:
|
||
|
|
- 'v*'
|
||
|
|
|
||
|
|
jobs:
|
||
|
|
deb:
|
||
|
|
runs-on: docker
|
||
|
|
container:
|
||
|
|
image: node:22-bookworm
|
||
|
|
steps:
|
||
|
|
- name: Check out tag
|
||
|
|
uses: actions/checkout@v4
|
||
|
|
|
||
|
|
- name: Run tests
|
||
|
|
run: npm ci && npm test
|
||
|
|
|
||
|
|
- name: Build .deb
|
||
|
|
run: bash scripts/build-deb.sh
|
||
|
|
|
||
|
|
- name: Publish to Debian registry
|
||
|
|
env:
|
||
|
|
STOKE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||
|
|
run: bash scripts/publish-deb.sh dist/stoke_*_all.deb heavy-duty stable main
|
||
|
|
|
||
|
|
- name: Create release and attach .deb
|
||
|
|
env:
|
||
|
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||
|
|
TAG: ${{ github.ref_name }}
|
||
|
|
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||
|
|
run: |
|
||
|
|
set -euo pipefail
|
||
|
|
DEB=$(ls dist/stoke_*_all.deb)
|
||
|
|
# Create the release if it does not exist yet, then grab its id.
|
||
|
|
RELEASE_ID=$(curl -sf -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG" | node -pe "JSON.parse(require('fs').readFileSync(0,'utf8')).id" 2>/dev/null || true)
|
||
|
|
if [ -z "$RELEASE_ID" ]; then
|
||
|
|
RELEASE_ID=$(curl -sf -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
|
||
|
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"draft\":false,\"prerelease\":false}" \
|
||
|
|
"$API/releases" | node -pe "JSON.parse(require('fs').readFileSync(0,'utf8')).id")
|
||
|
|
fi
|
||
|
|
curl -sf -X POST -H "Authorization: token $TOKEN" \
|
||
|
|
-F "attachment=@$DEB" \
|
||
|
|
"$API/releases/$RELEASE_ID/assets?name=$(basename "$DEB")" >/dev/null
|
||
|
|
echo "Attached $(basename "$DEB") to release $TAG"
|