# Builds the desktop controller on every push to main and publishes it as a release. # Needs a Gitea Actions runner with the label "ubuntu-latest" and cmake, make, gcc and python3 installed. name: release on: push: branches: - main jobs: release: runs-on: ubuntu-latest permissions: contents: write steps: - name: Check out the code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Build the desktop controller run: make desktop - name: Package the build id: pkg run: | TAG="v$(date -u +%Y.%m.%d)-$(git rev-parse --short HEAD)" mkdir -p dist cp build-desktop/led-controller "dist/led-controller-${TAG}-linux-x86_64" (cd dist && sha256sum "led-controller-${TAG}-linux-x86_64" > SHA256SUMS) echo "tag=${TAG}" >> "$GITHUB_OUTPUT" - name: Create the release and upload the files env: TAG: ${{ steps.pkg.outputs.tag }} TOKEN: ${{ github.token }} run: | API="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}" RESP=$(curl -sS -f -X POST "${API}/releases" \ -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"${GITHUB_SHA}\",\"name\":\"${TAG}\",\"body\":\"Built from ${GITHUB_SHA} on main.\",\"draft\":false,\"prerelease\":false}") ID=$(echo "$RESP" | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])') for f in dist/*; do curl -sS -f -X POST "${API}/releases/${ID}/assets?name=$(basename "$f")" \ -H "Authorization: token ${TOKEN}" -H "Content-Type: application/octet-stream" \ --data-binary "@${f}" > /dev/null done echo "Released ${TAG}"