Skip to content

Commit dd8bd5c

Browse files
committed
Merge pull request 'ci: add GitHub Actions workflows to Gitea main' (#6) from fix/add-github-workflows into main
2 parents ab89d3d + 7a56128 commit dd8bd5c

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dtolnay/rust-toolchain@stable
19+
with:
20+
components: rustfmt, clippy
21+
- uses: Swatinem/rust-cache@v2
22+
- run: cargo fmt --all -- --check
23+
- run: cargo clippy --workspace --all-targets -- -D warnings
24+
- run: cargo build --workspace
25+
- run: cargo test --workspace --lib --no-fail-fast
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish Crates
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
crate_list:
6+
description: Space-separated crate package names to publish in order
7+
required: true
8+
type: string
9+
dry_run:
10+
description: Run cargo publish --dry-run only
11+
required: false
12+
default: "true"
13+
type: choice
14+
options: ["true", "false"]
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
publish:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dtolnay/rust-toolchain@stable
27+
- uses: Swatinem/rust-cache@v2
28+
- uses: 1password/install-cli-action@v2
29+
- name: Get crates.io token from 1Password
30+
id: token
31+
env:
32+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
33+
run: |
34+
TOKEN=$(op read "op://TerraphimPlatform/crates.io.token/token")
35+
echo "token=$TOKEN" >> $GITHUB_OUTPUT
36+
- name: Publish crates in dependency order
37+
env:
38+
CARGO_REGISTRY_TOKEN: ${{ steps.token.outputs.token }}
39+
CRATE_LIST: ${{ inputs.crate_list }}
40+
DRY_RUN: ${{ inputs.dry_run }}
41+
run: |
42+
set -euo pipefail
43+
for crate in $CRATE_LIST; do
44+
manifest="crates/$crate/Cargo.toml"
45+
if [ ! -f "$manifest" ]; then
46+
echo "Missing manifest for $crate at $manifest" >&2
47+
exit 1
48+
fi
49+
version=$(grep -m1 '^version' "$manifest" | sed 's/.*"\(.*\)".*//')
50+
if curl -fsS "https://crates.io/api/v1/crates/$crate/$version" >/dev/null 2>&1; then
51+
echo "$crate $version already exists on crates.io; skipping"
52+
continue
53+
fi
54+
if [ "$DRY_RUN" = "true" ]; then
55+
cargo publish --manifest-path "$manifest" --dry-run
56+
else
57+
cargo publish --manifest-path "$manifest"
58+
fi
59+
done

0 commit comments

Comments
 (0)