45 lines
1.2 KiB
YAML
45 lines
1.2 KiB
YAML
name: Publish crate
|
|
|
|
# Save as .gitea/workflows/publish.yml
|
|
# Publishes when you push a tag like v0.1.0 (the tag should match Cargo.toml's version).
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
# Registry is named "gitea" and points at the owner of the current repo.
|
|
# github.server_url / github.repository_owner are populated by Gitea Actions.
|
|
CARGO_REGISTRIES_GITEA_INDEX: "sparse+${{ github.server_url }}/api/packages/${{ github.repository_owner }}/cargo/"
|
|
CARGO_REGISTRIES_GITEA_TOKEN: "Bearer ${{ secrets.CARGO_REGISTRY_TOKEN }}"
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Cache cargo
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: ${{ runner.os }}-cargo-
|
|
|
|
- name: Build
|
|
run: cargo build --release --locked
|
|
|
|
- name: Test
|
|
run: cargo test --locked
|
|
|
|
- name: Publish to Gitea registry
|
|
run: cargo publish --registry gitea --locked
|