Skip to content

Commit 7c492c8

Browse files
authored
Initial commit
0 parents  commit 7c492c8

File tree

10 files changed

+212
-0
lines changed

10 files changed

+212
-0
lines changed

.github/dependabot.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
# Check for updates every Monday
6+
schedule:
7+
interval: "weekly"

.github/workflows/cargo.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Rust CI
2+
on:
3+
pull_request:
4+
branches:
5+
- '**'
6+
push:
7+
branches:
8+
- '**'
9+
# - '!master'
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
CI:
16+
runs-on: ubuntu-latest
17+
name: cargo CI
18+
permissions:
19+
# Give the default GITHUB_TOKEN write permission to commit and push the
20+
# added or changed files to the repository.
21+
contents: write
22+
steps:
23+
- name: get repo
24+
uses: actions/checkout@v4
25+
- name: install rust
26+
uses: dtolnay/rust-toolchain@stable
27+
- name: install additional rust things
28+
run: |
29+
rustup component add rustfmt
30+
rustup component add clippy
31+
- name: config custom registry
32+
run: |
33+
mkdir -p ~/.cargo/
34+
echo "" > ~/.cargo/config.toml
35+
echo "[registry]" >> ~/.cargo/config.toml
36+
echo 'cscherr = "cscherr"' >> ~/.cargo/config.toml
37+
echo '[registries.cscherr]' >> ~/.cargo/config.toml
38+
echo 'index = "https://git.cscherr.de/PlexSheep/_cargo-index.git"' >> ~/.cargo/config.toml
39+
cat ~/.cargo/config.toml
40+
- name: cargo clippy check
41+
run: cargo clippy --all-features --all-targets --workspace
42+
- name: cargo clippy fix
43+
run: cargo clippy --fix --all-features --all-targets --workspace
44+
- name: cargo fmt
45+
run: cargo fmt --all
46+
- name: cargo test
47+
run: cargo test --all-features --all-targets --workspace
48+
- name: commit back to repository
49+
uses: stefanzweifel/git-auto-commit-action@v5
50+
with:
51+
# Optional. Commit message for the created commit.
52+
# Defaults to "Apply automatic changes"
53+
commit_message: "ci: automatic Rust CI changes"

.github/workflows/release.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release-plz
2+
3+
permissions:
4+
pull-requests: write
5+
contents: write
6+
7+
on:
8+
push:
9+
branches:
10+
- master
11+
- main
12+
13+
jobs:
14+
15+
# Release unpublished packages.
16+
release-plz-release:
17+
name: Release-plz release
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Install Rust toolchain
25+
uses: dtolnay/rust-toolchain@stable
26+
- name: Run release-plz
27+
uses: MarcoIeni/[email protected]
28+
with:
29+
command: release
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
33+
34+
# Create a PR with the new versions and changelog, preparing the next release.
35+
release-plz-pr:
36+
name: Release-plz PR
37+
runs-on: ubuntu-latest
38+
concurrency:
39+
group: release-plz-${{ github.ref }}
40+
cancel-in-progress: false
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
46+
- name: Install Rust toolchain
47+
uses: dtolnay/rust-toolchain@stable
48+
- name: Run release-plz
49+
uses: MarcoIeni/[email protected]
50+
with:
51+
command: release-pr
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ---> Rust
2+
# Generated by Cargo
3+
# will have compiled files and executables
4+
debug/
5+
target/
6+
7+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
8+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
9+
Cargo.lock
10+
11+
# These are backup files generated by rustfmt
12+
**/*.rs.bk
13+
14+
# MSVC Windows builds of rustc generate these, which store debugging information
15+
*.pdb
16+
17+
18+
19+
# Added by cargo
20+
21+
/target

Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "base"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
authors = ["Christoph J. Scherr <[email protected]>"]
7+
license = "GPL-3.0-or-later"
8+
description = "No description yet"
9+
readme = "README.md"
10+
homepage = "https://git.cscherr.de/PlexSheep/rs-base"
11+
repository = "https://git.cscherr.de/PlexSheep/rs-base"
12+
keywords = ["template"]
13+
14+
15+
[dependencies]

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2024 PlexSheep
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# rs-base
2+
3+
<!-- TODO: replace 'base' with crate name and remove comments -->
4+
![Project badge](https://img.shields.io/badge/language-Rust-blue.svg)
5+
![Crates.io License](https://img.shields.io/crates/l/base)
6+
![GitHub Release](https://img.shields.io/github/v/release/PlexSheep/base)
7+
![GitHub language count](https://img.shields.io/github/languages/count/PlexSheep/base)
8+
[![Rust CI](https://github.com/PlexSheep/base/actions/workflows/cargo.yaml/badge.svg)](https://github.com/PlexSheep/hedu/actions/workflows/cargo.yaml)
9+
10+
11+
Base repository for rust projects
12+
13+
* [GitHub](https://github.com/PlexSheep/base)
14+
* [crates.io](https://crates.io/crates/base)
15+
* [docs.rs](https://docs.rs/crate/base/)

scripts/publish.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
cargo check --all-features
4+
echo ">>>>>>>> PUBLISHING RELEASE FOR REPO"
5+
bash scripts/release.sh
6+
echo ">>>>>>>> PUBLISHING TO CRATES.IO NEXT"
7+
sleep 2
8+
cargo publish
9+
echo ">>>>>>>> PUBLISHING TO CSCHERR.DE NEXT"
10+
sleep 2
11+
cargo publish --registry cscherr

scripts/release.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
TOKEN=$(cat ~/.git-credentials | grep 'git.cscherr.de' | grep -P '(?:)[^:]*(?=@)' -o)
3+
NEW_VERSION=$(cat Cargo.toml | rg '^\s*version\s*=\s*"([^"]*)"\s*$' -or '$1')
4+
GIT_COMMIT_SHA=$(git rev-parse HEAD)
5+
REPO=${PWD##*/} # name of cwd
6+
BODY="
7+
$(git log $(git describe --tags --abbrev=0)..HEAD --pretty="- %s" --oneline --no-decorate)
8+
"
9+
USER=PlexSheep
10+
git tag "v$NEW_VERSION" || echo "could not tag"
11+
curl -X 'POST' \
12+
'https://git.cscherr.de/api/v1/repos/PlexSheep/'$REPO'/releases' \
13+
-H 'accept: application/json' \
14+
-H "Authorization: token $TOKEN" \
15+
-H 'Content-Type: application/json' \
16+
-d '{
17+
"body": "'"$BODY"'",
18+
"draft": false,
19+
"name": "v'$NEW_VERSION'",
20+
"prerelease": true,
21+
"tag_name": "v'$NEW_VERSION'",
22+
"target_commitish": "'$GIT_COMMIT_SHA'"
23+
}' | python -m json.tool
24+
git push || echo "could not push"

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

0 commit comments

Comments
 (0)