Files
forust 1a77043a71 fix: editor split, stop flag in actions, write errors, history on failure, expect panic, string match
- src/main.rs: split VISUAL/EDITOR into prog+args, drop expect panic in reap_timer, propagate write_timer errors, check stop during actions, record history on partial failure, use const for stop msg
- Cargo.toml: add authors/homepage, bump noyalib 0.0.12->0.0.13
- release.yaml: tighten tag glob, fix curl 404 fallback, URI-encode asset name, upgrade upload-artifact v3->v4
- ci.yaml: add cargo cache step
- README.md: sync feature list, fix push to two-step
- RELEASING.md: clarify Cargo.lock regeneration
2026-07-07 23:13:19 +02:00

127 lines
3.9 KiB
YAML

name: release
"on":
push:
tags:
- "v[0-9]*.[0-9]*.[0-9]*"
workflow_dispatch:
permissions:
contents: write
jobs:
verify:
runs-on: [self-hosted, linux, arch, homelab]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check formatting
shell: bash
run: cargo fmt --check
- name: Run tests
shell: bash
run: cargo test --locked
- name: Run clippy
shell: bash
run: cargo clippy --locked -- -D warnings
- name: Lint YAML
shell: bash
run: |
docker run --rm \
-v "$PWD:/work" \
-w /work \
cytopia/yamllint:latest \
-c .yamllint .
linux-amd64:
needs: verify
runs-on: [self-hosted, linux, arch, homelab]
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build release binary
shell: bash
run: cargo build --release --locked
- name: Package artifact
shell: bash
run: |
tag="${GITHUB_REF##*/}"
version="${tag#v}"
mkdir -p dist
binary="gosleep-timer-${version}-linux-amd64"
cp target/release/gosleep-timer "dist/${binary}"
cd dist
sha256sum "${binary}" > "${binary}.sha256"
- name: Create Gitea release
id: release
shell: bash
run: |
tag="${GITHUB_REF##*/}"
release_url="https://gitea.forust.xyz/api/v1/repos/forust/gosleep/releases"
existing="$(curl -fsS \
"${release_url}/tags/${tag}" \
-H "Authorization: token ${GITEA_TOKEN}")" || existing='{}'
release_id="$(printf '%s' "$existing" | jq -r '.id // empty')"
if [ -z "$release_id" ]; then
body="$(cat <<EOF
Release ${tag}
See CHANGELOG.md for notable changes.
EOF
)"
payload="$(jq -n \
--arg tag "${tag}" \
--arg commit "${GITHUB_SHA}" \
--arg name "gosleep-timer ${tag}" \
--arg body "$body" \
'{tag_name: $tag, target_commitish: $commit, name: $name, body: $body, draft: false, prerelease: false}')"
response="$(curl -fsS \
-X POST "${release_url}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "$payload")"
release_id="$(printf '%s' "$response" | jq -r '.id')"
fi
test -n "$release_id" && test "$release_id" != "null"
echo "release_id=${release_id}" >> "$GITHUB_OUTPUT"
- name: Upload Gitea release assets
shell: bash
run: |
release_url="https://gitea.forust.xyz/api/v1/repos/forust/gosleep/releases"
release_id="${{ steps.release.outputs.release_id }}"
for asset in dist/gosleep-timer-*; do
name="$(basename "$asset")"
release="$(curl -fsS \
"${release_url}/${release_id}" \
-H "Authorization: token ${GITEA_TOKEN}")"
asset_id="$(printf '%s' "$release" | jq -r --arg name "$name" '.assets[]? | select(.name == $name) | .id' | head -n 1)"
if [ -n "$asset_id" ]; then
curl -fsS \
-X DELETE "${release_url}/${release_id}/assets/${asset_id}" \
-H "Authorization: token ${GITEA_TOKEN}"
fi
encoded="$(printf '%s' "$name" | jq -sRr @uri)"
curl -fsS \
-X POST "${release_url}/${release_id}/assets?name=${encoded}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@${asset}"
done
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gosleep-timer-linux-amd64
path: dist/*