55 lines
2.1 KiB
YAML
55 lines
2.1 KiB
YAML
# Gitea Actions (GitHub-Actions-compatible). NOT YET RUN: untested on a real runner.
|
|
# Assumptions:
|
|
# - A runner labelled `ubuntu-latest` (adjust `runs-on`) with Docker/Node available for actions.
|
|
# - Nim and zig are installed via devbox (jetify-com/devbox-install-action); the nix store is fetched from cache.nixos.org.
|
|
# - Release upload goes through the Gitea REST API (curl) with the built-in token
|
|
# `${{ github.token }}` (Gitea maps it to GITEA_TOKEN); the token must be allowed to write releases.
|
|
# This avoids depending on third-party release actions that target GitHub only.
|
|
name: ci
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
tags: ["v*"]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: jetify-com/devbox-install-action@v0.13.0
|
|
with:
|
|
enable-cache: "false"
|
|
- run: devbox run test
|
|
|
|
release:
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: jetify-com/devbox-install-action@v0.13.0
|
|
with:
|
|
enable-cache: "false"
|
|
- name: Build all targets
|
|
run: devbox run cross-all
|
|
- name: Checksums
|
|
run: cd dist && sha256sum sirmem-* > SHA256SUMS && cat SHA256SUMS
|
|
- name: Create release and upload assets
|
|
env:
|
|
TOKEN: ${{ github.token }}
|
|
SERVER: ${{ github.server_url }}
|
|
REPO: ${{ github.repository }}
|
|
TAG: ${{ github.ref_name }}
|
|
run: |
|
|
set -euo pipefail
|
|
api="$SERVER/api/v1/repos/$REPO"
|
|
id=$(curl -fsS -X POST "$api/releases" \
|
|
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\"}" | sed -n 's/.*"id":\([0-9]*\).*/\1/p' | head -1)
|
|
for f in dist/*; do
|
|
curl -fsS -X POST "$api/releases/$id/assets?name=$(basename "$f")" \
|
|
-H "Authorization: token $TOKEN" -F "attachment=@$f"
|
|
done
|