update readme and add action
Some checks failed
Release crate / Publish to crates.io and create GitHub Release (release) Failing after 1m48s
Some checks failed
Release crate / Publish to crates.io and create GitHub Release (release) Failing after 1m48s
This commit is contained in:
80
.github/workflows/release.yml
vendored
Normal file
80
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
name: Release crate
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
|
||||
env:
|
||||
GITEA_BASE_URL: http://gitea
|
||||
REGISTRY_OWNER: ${{ github.repository_owner }}
|
||||
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Publish to crates.io and create GitHub Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Cache cargo registry and git index
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Build and test
|
||||
run: cargo test --workspace --verbose
|
||||
|
||||
- name: Install cargo-edit and set crate version
|
||||
id: set_version
|
||||
run: |
|
||||
cargo install cargo-edit --locked --force
|
||||
TAG="${{ github.event.release.tag_name }}"
|
||||
VERSION="${TAG#v}"
|
||||
cargo set-version "$VERSION" --workspace
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Configure Cargo registries (crates.io default + add Gitea)
|
||||
shell: bash
|
||||
env:
|
||||
TOKEN: ${{ secrets.CARGO_GITEA_TOKEN }}
|
||||
run: |
|
||||
mkdir -p ~/.cargo
|
||||
# crates.io stays default
|
||||
cat > ~/.cargo/config.toml <<'EOF'
|
||||
[registry]
|
||||
default = "crates-io"
|
||||
EOF
|
||||
|
||||
# Add Gitea as extra registry (sparse index recommended)
|
||||
{
|
||||
echo "[registries.gitea]"
|
||||
echo "index = \"sparse+${GITEA_BASE_URL}/api/packages/${REGISTRY_OWNER}/cargo/\""
|
||||
} >> ~/.cargo/config.toml
|
||||
|
||||
# Auth for Gitea registry
|
||||
umask 077
|
||||
cat > ~/.cargo/credentials.toml <<EOF
|
||||
[registries.gitea]
|
||||
token = "Bearer ${TOKEN}"
|
||||
EOF
|
||||
|
||||
- name: Publish to Gitea registry
|
||||
run: cargo publish --registry gitea
|
||||
|
||||
# - name: Publish to crates.io
|
||||
# env:
|
||||
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
# run: |
|
||||
# if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
|
||||
# echo "CARGO_REGISTRY_TOKEN is not set. Set it in repository secrets to publish to crates.io"
|
||||
# exit 1
|
||||
# fi
|
||||
# cargo publish --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
target
|
||||
Cargo.lock
|
||||
shell.nix
|
||||
dist
|
||||
generated_cards
|
||||
main.rs
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "schafkopf-logic"
|
||||
version = "0.1.0"
|
||||
version = "0.0.0"
|
||||
edition = "2024"
|
||||
description = "Logic and rules for the Schafkopf card game: deck, suits, ranks and game modes."
|
||||
license = "MIT"
|
||||
|
||||
12
README.md
12
README.md
@@ -14,7 +14,7 @@ Logic and rules for the German card game Schafkopf. This crate provides types
|
||||
and helpers for deck construction, common game modes and basic trick-taking
|
||||
logic.
|
||||
|
||||
**Crate:** `schafkopf-logic` • **Version:** 0.1.0
|
||||
**Crate:** [`schafkopf-logic`](https://crates.io/crates/schafkopf-logic)
|
||||
|
||||
## Features
|
||||
|
||||
@@ -36,13 +36,13 @@ fn main() {
|
||||
deck.shuffle();
|
||||
let hands = deck.deal_4x8().expect("deck should contain 32 cards");
|
||||
|
||||
// form a sample trick from the first card of each hand
|
||||
// Form a sample trick from the first card of each hand and print it
|
||||
let trick = [&hands[0][0], &hands[1][0], &hands[2][0], &hands[3][0]];
|
||||
let winner = Gamemode::Sauspiel(Suit::Herz).winning_card(trick);
|
||||
println!("Winning card: {}", winner);
|
||||
println!("Trick: {}, {}, {}, {}", trick[0], trick[1], trick[2], trick[3]);
|
||||
|
||||
// rank points example
|
||||
assert_eq!(Rank::Ass.points(), 11);
|
||||
// Determine the winner for a sample game mode (Sauspiel with Schell)
|
||||
let winner = Gamemode::Sauspiel(Suit::Schell).winning_card(trick);
|
||||
println!("Winning card: {}", winner);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
18
shell.nix
Normal file
18
shell.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
let
|
||||
pkgs = import <nixpkgs> {};
|
||||
in
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
cargo
|
||||
rustc
|
||||
rustPackages.clippy
|
||||
pkg-config
|
||||
gnupg
|
||||
pinentry
|
||||
pinentry-curses
|
||||
];
|
||||
shellHook = ''
|
||||
# Export GPG_TTY so pinentry-curses can attach to the current terminal
|
||||
export GPG_TTY=$(tty)
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user