@@ -0,0 +1,19 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: pixi-build-rust
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install the pinned toolchain
|
||||
run: pixi install
|
||||
|
||||
- name: Verify (formatting, lint, tests, docs)
|
||||
run: pixi run check
|
||||
@@ -0,0 +1,67 @@
|
||||
name: Deploy docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['*.*.*']
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
SITE_SLUG: coursebank
|
||||
CRATE: coursebank
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: pixi-build-rust
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Write the channel switcher
|
||||
run: |
|
||||
cat > "${{ gitea.workspace }}/docs-banner.html" <<'HTML'
|
||||
<div style="padding:.4rem .75rem;font:0.85rem/1.4 sans-serif;border-bottom:1px solid var(--border-color,#ddd);background:var(--sidebar-background-color,#f7f7f7);color:var(--main-color,#000)">
|
||||
Docs channel:
|
||||
<a id="ch-release" href="#" style="margin:0 .35rem">release</a>|
|
||||
<a id="ch-nightly" href="#" style="margin:0 .35rem">nightly</a>
|
||||
<script>
|
||||
(function () {
|
||||
var m = location.pathname.match(/^(.*\/)(release|nightly)\//);
|
||||
var base = m ? m[1] : location.pathname.replace(/[^\/]*$/, "");
|
||||
document.getElementById("ch-release").href = base + "release/";
|
||||
document.getElementById("ch-nightly").href = base + "nightly/";
|
||||
if (m) { document.getElementById("ch-" + m[2]).style.fontWeight = "bold"; }
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
HTML
|
||||
|
||||
- name: Build the API docs
|
||||
env:
|
||||
RUSTDOCFLAGS: "--html-before-content ${{ gitea.workspace }}/docs-banner.html"
|
||||
run: |
|
||||
pixi install --locked
|
||||
pixi run doc-build
|
||||
|
||||
- name: Redirect the channel root to the crate page
|
||||
run: |
|
||||
printf '%s\n' "<!doctype html><meta http-equiv=\"refresh\" content=\"0; url=${CRATE}/\">" > target/doc/index.html
|
||||
|
||||
- name: Publish the channel to /srv/www
|
||||
run: |
|
||||
case "${{ gitea.ref }}" in
|
||||
refs/tags/*) channel=release ;;
|
||||
*) channel=nightly ;;
|
||||
esac
|
||||
dest="/srv/www/${SITE_SLUG}/${channel}"
|
||||
mkdir -p "$dest"
|
||||
rsync -a --delete "target/doc/" "$dest/"
|
||||
|
||||
- name: Point the site root at the latest release, else nightly
|
||||
run: |
|
||||
root="/srv/www/${SITE_SLUG}"
|
||||
if [ -d "$root/release/${CRATE}" ]; then
|
||||
target="release/${CRATE}/"
|
||||
else
|
||||
target="nightly/${CRATE}/"
|
||||
fi
|
||||
printf '%s\n' "<!doctype html><meta http-equiv=\"refresh\" content=\"0; url=${target}\">" > "$root/index.html"
|
||||
@@ -0,0 +1,71 @@
|
||||
name: Nightly
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '0 6 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
nightly:
|
||||
runs-on: pixi-build-rust
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
TAG: nightly
|
||||
ASSET: coursebank-nightly-linux-x64.tar.gz
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install the pinned toolchain
|
||||
run: pixi install
|
||||
|
||||
- name: Build the release binary
|
||||
run: pixi run build
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
set -euo pipefail
|
||||
tar -czf "$ASSET" \
|
||||
-C target/release coursebank \
|
||||
-C "${{ gitea.workspace }}" LICENSE.md
|
||||
sha256sum "$ASSET" > "$ASSET.sha256"
|
||||
|
||||
- name: Publish the rolling nightly prerelease
|
||||
run: |
|
||||
set -euo pipefail
|
||||
auth="Authorization: token ${TOKEN}"
|
||||
# jq is fetched on demand; no toolchain change needed for it.
|
||||
jq() { pixi exec --spec jq -- jq "$@"; }
|
||||
|
||||
sha="${{ gitea.sha }}"
|
||||
version=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
body="Nightly build of ${version} at $(date -u +%Y-%m-%d) (commit ${sha:0:8}). Not a stable release."
|
||||
|
||||
# Drop the previous nightly release and its moving tag, if present, so
|
||||
# the new one points at the current commit.
|
||||
existing=$(curl -fsSL -H "$auth" "${API}/releases/tags/${TAG}" 2>/dev/null || true)
|
||||
if [ -n "$existing" ]; then
|
||||
id=$(printf '%s' "$existing" | jq -r '.id // empty')
|
||||
[ -n "$id" ] && curl -fsSL -X DELETE -H "$auth" "${API}/releases/${id}"
|
||||
fi
|
||||
curl -fsSL -X DELETE -H "$auth" "${API}/tags/${TAG}" 2>/dev/null || true
|
||||
|
||||
# Create the release at the current commit.
|
||||
rid=$(curl -fsSL -X POST -H "$auth" -H "Content-Type: application/json" \
|
||||
"${API}/releases" \
|
||||
-d "$(jq -n --arg tag "$TAG" --arg sha "$sha" --arg body "$body" \
|
||||
'{tag_name:$tag, target_commitish:$sha, name:"Nightly", body:$body, draft:false, prerelease:true}')" \
|
||||
| jq -r '.id')
|
||||
|
||||
# Attach the tarball and its checksum.
|
||||
for f in "$ASSET" "$ASSET.sha256"; do
|
||||
curl -fsSL -X POST -H "$auth" \
|
||||
-F "attachment=@${f}" \
|
||||
"${API}/releases/${rid}/assets?name=${f}"
|
||||
done
|
||||
@@ -0,0 +1,61 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*.*.*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: pixi-build-rust
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
TAG: ${{ gitea.ref_name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check the tag matches the crate version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
version=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
tag="${TAG#v}"
|
||||
if [ "$tag" != "$version" ]; then
|
||||
echo "tag ${TAG} does not match Cargo.toml version ${version}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install the pinned toolchain
|
||||
run: pixi install
|
||||
|
||||
- name: Build the full bundle (binary and license notices)
|
||||
run: |
|
||||
pixi run setup-tools
|
||||
pixi run dist
|
||||
|
||||
- name: Package and publish the release
|
||||
run: |
|
||||
set -euo pipefail
|
||||
auth="Authorization: token ${TOKEN}"
|
||||
jq() { pixi exec --spec jq -- jq "$@"; }
|
||||
|
||||
version=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
asset="coursebank-${version}-linux-x64.tar.gz"
|
||||
tar -czf "$asset" -C dist coursebank LICENSE.md THIRD-PARTY-LICENSES.txt
|
||||
sha256sum "$asset" > "$asset.sha256"
|
||||
|
||||
rid=$(curl -fsSL -X POST -H "$auth" -H "Content-Type: application/json" \
|
||||
"${API}/releases" \
|
||||
-d "$(jq -n --arg tag "$TAG" \
|
||||
'{tag_name:$tag, name:$tag, body:"See CHANGELOG.md.", draft:false, prerelease:false}')" \
|
||||
| jq -r '.id')
|
||||
|
||||
for f in "$asset" "$asset.sha256"; do
|
||||
curl -fsSL -X POST -H "$auth" \
|
||||
-F "attachment=@${f}" \
|
||||
"${API}/releases/${rid}/assets?name=${f}"
|
||||
done
|
||||
@@ -0,0 +1,36 @@
|
||||
name: Sync README to GitHub
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'README.md'
|
||||
- '.gitea/workflows/sync-readme.yml'
|
||||
- '.gitea/notice.md'
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: github-readme-sync
|
||||
steps:
|
||||
- name: Check out the Gitea repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build the combined README
|
||||
run: |
|
||||
cat README.md > combined.md
|
||||
printf '\n\n' >> combined.md
|
||||
cat .gitea/notice.md >> combined.md
|
||||
|
||||
- name: Push to the GitHub mirror
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_MIRROR_TOKEN }}
|
||||
run: |
|
||||
git clone --depth 1 \
|
||||
"https://x-access-token:${GH_TOKEN}@github.com/scienting/coursebank.git" ghmirror
|
||||
cp combined.md ghmirror/README.md
|
||||
cd ghmirror
|
||||
git config user.name "Alex Maldonado"
|
||||
git config user.email "alexm@scient.ing"
|
||||
git add README.md
|
||||
git diff --cached --quiet || git commit -m "Sync README from Gitea"
|
||||
git push
|
||||
Reference in New Issue
Block a user