78 lines
2.6 KiB
YAML
78 lines
2.6 KiB
YAML
name: Release
|
|
|
|
# Push a tag such as v0.1.0 to build a static Linux binary (web UI included)
|
|
# and publish it as a Gitea release. The tag must match the version in
|
|
# Cargo.toml's [workspace.package].
|
|
#
|
|
# Written for Gitea Actions (act_runner). It lives in .github/workflows so the
|
|
# CI workflow next to it keeps running too: Gitea ignores .github/workflows
|
|
# once a .gitea/workflows folder exists.
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
TARGET: x86_64-unknown-linux-musl
|
|
ZIG_VERSION: 0.17.0
|
|
CARGO_TERM_COLOR: always
|
|
CARGO_PROFILE_RELEASE_STRIP: symbols
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Check the tag matches Cargo.toml
|
|
run: |
|
|
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
|
|
if [ "$GITHUB_REF_NAME" != "v$version" ]; then
|
|
echo "::error::Tag $GITHUB_REF_NAME doesn't match Cargo.toml version $version. Bump the version or fix the tag."
|
|
exit 1
|
|
fi
|
|
|
|
- uses: actions/setup-node@v4
|
|
with: { node-version: 22, cache: npm, cache-dependency-path: ui/package-lock.json }
|
|
- name: Build the UI
|
|
run: |
|
|
npm --prefix ui ci
|
|
npm --prefix ui run check
|
|
npm --prefix ui run build
|
|
test -f ui/dist/index.html
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with: { targets: "${{ env.TARGET }}" }
|
|
- uses: mlugg/setup-zig@v2
|
|
with: { version: "${{ env.ZIG_VERSION }}" }
|
|
- uses: taiki-e/install-action@v2
|
|
with: { tool: cargo-zigbuild }
|
|
- uses: Swatinem/rust-cache@v2
|
|
with: { key: "${{ env.TARGET }}" }
|
|
|
|
- name: Test
|
|
run: cargo test --workspace --locked
|
|
|
|
# musl + zig gives one static binary with no glibc version to match on
|
|
# the server.
|
|
- name: Build
|
|
run: cargo zigbuild --release --locked --target "$TARGET" -p jellymove
|
|
|
|
- name: Package
|
|
run: |
|
|
name="jellymove-$GITHUB_REF_NAME-$TARGET"
|
|
mkdir -p "dist/$name"
|
|
cp "target/$TARGET/release/jellymove" deploy/jellymove.service \
|
|
config.example.toml README.md "dist/$name/"
|
|
"dist/$name/jellymove" --version
|
|
tar -C dist -czf "dist/$name.tar.gz" "$name"
|
|
(cd dist && sha256sum "$name.tar.gz" > "$name.tar.gz.sha256")
|
|
echo "ASSET=dist/$name.tar.gz" >> "$GITHUB_ENV"
|
|
|
|
- name: Publish the release
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: node .github/scripts/gitea-release.mjs "$GITHUB_REF_NAME" "$ASSET" "$ASSET.sha256"
|