Skip to content

Commit d023c2b

Browse files
committed
Initial commit
0 parents  commit d023c2b

13 files changed

+2861
-0
lines changed

.github/dependabot.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Please see the documentation for all configuration options:
2+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
- package-ecosystem: "cargo"
7+
directory: "/"
8+
target-branch: main
9+
schedule:
10+
interval: "daily"

.github/workflows/build_and_test.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and test
2+
on:
3+
pull_request:
4+
branches: [main]
5+
workflow_dispatch:
6+
jobs:
7+
build_and_test:
8+
name: Build and test
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
env: [ubuntu-64, macos-64, windows-64]
13+
include:
14+
- env: ubuntu-64
15+
os: ubuntu-latest
16+
toolchain: stable-x86_64-unknown-linux-gnu
17+
- env: macos-64
18+
os: macos-latest
19+
toolchain: stable-x86_64-apple-darwin
20+
- env: windows-64
21+
os: windows-latest
22+
toolchain: stable-x86_64-pc-windows-msvc
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
- name: Setup Rust toolchain ${{ matrix.toolchain }} for ${{ matrix.os }}
27+
uses: actions-rs/toolchain@v1
28+
with:
29+
toolchain: ${{ matrix.toolchain }}
30+
override: true
31+
- name: Setup Cargo cache
32+
uses: Swatinem/rust-cache@v2
33+
- name: Test using ${{ matrix.toolchain }} for ${{ matrix.os }}
34+
uses: actions-rs/cargo@v1
35+
with:
36+
command: test
37+
args: --release --all-features
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish pre-release
2+
on:
3+
push:
4+
branches: [main]
5+
jobs:
6+
github:
7+
name: Publish GitHub
8+
permissions:
9+
contents: write
10+
environment: GITHUB_PRE_RELEASE
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest
16+
uses: actions-rs/toolchain@v1
17+
with:
18+
toolchain: stable-x86_64-unknown-linux-gnu
19+
override: true
20+
- name: Setup Cargo cache
21+
uses: Swatinem/rust-cache@v2
22+
- name: Package
23+
uses: actions-rs/cargo@v1
24+
with:
25+
command: package
26+
args: --all-features
27+
- name: Read crate name
28+
id: crate_name
29+
run: echo "crate_name=$(cargo read-manifest | jq -r .name)" >> $GITHUB_OUTPUT
30+
- name: Read version
31+
id: version
32+
run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT
33+
- name: Read git commit hash
34+
id: commit_hash
35+
run: echo "commit_hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
36+
- name: Create release
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions
39+
run: gh release create "${{ steps.commit_hash.outputs.commit_hash }}" --repo="$GITHUB_REPOSITORY" --target main --title="Pre-Release ${{ steps.commit_hash.outputs.commit_hash }} (${{ steps.version.outputs.version }})" --generate-notes --prerelease "./target/package/${{ steps.crate_name.outputs.crate_name }}-${{ steps.version.outputs.version }}.crate"

.github/workflows/deploy_release.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Publish release
2+
on:
3+
push:
4+
branches: [release/**]
5+
jobs:
6+
check_version_bump:
7+
name: Check version bump
8+
environment: CRATES_IO
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest
14+
uses: actions-rs/toolchain@v1
15+
with:
16+
toolchain: stable-x86_64-unknown-linux-gnu
17+
override: true
18+
- name: Read source branch version
19+
id: source_version
20+
run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT
21+
- name: Update cargo index
22+
run: cargo search
23+
- name: Read crates.io version
24+
id: crates_io_version
25+
run: echo "version=$(cargo search --limit 1 $(cargo read-manifest | jq -r .name) | grep -oP '(?<=")([0-9]+.[0-9]+.[0-9]+)(?=")')" >> $GITHUB_OUTPUT
26+
- name: Parse and compare versions
27+
run: |
28+
source_version="${{ steps.source_version.outputs.version }}"
29+
crates_io_version="${{ steps.crates_io_version.outputs.version }}"
30+
if [ "$(printf '%s\n' "$crates_io_version" "$source_version" | sort -V | head -n1)" != "$source_version" ]; then
31+
echo "Source branch version ($source_version) is higher than crates.io version ($crates_io_version)."
32+
else
33+
echo "Source branch version ($source_version) is not higher than crates.io version ($crates_io_version)."
34+
exit 1
35+
fi
36+
crates_io:
37+
name: Publish crates.io
38+
needs: check_version_bump
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v2
43+
- name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest
44+
uses: actions-rs/toolchain@v1
45+
with:
46+
toolchain: stable-x86_64-unknown-linux-gnu
47+
override: true
48+
- name: Setup Cargo cache
49+
uses: Swatinem/rust-cache@v2
50+
- name: Login to crates.io
51+
uses: actions-rs/cargo@v1
52+
with:
53+
command: login
54+
args: ${{ secrets.CRATES_IO_TOKEN }}
55+
- name: Publish to crates.io
56+
uses: actions-rs/cargo@v1
57+
with:
58+
command: publish
59+
github:
60+
name: Publish GitHub
61+
needs: crates_io
62+
permissions:
63+
contents: write
64+
environment: GITHUB_RELEASE
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v2
69+
- name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest
70+
uses: actions-rs/toolchain@v1
71+
with:
72+
toolchain: stable-x86_64-unknown-linux-gnu
73+
override: true
74+
- name: Setup Cargo cache
75+
uses: Swatinem/rust-cache@v2
76+
- name: Package
77+
uses: actions-rs/cargo@v1
78+
with:
79+
command: package
80+
args: --all-features
81+
- name: Read crate name
82+
id: crate_name
83+
run: echo "crate_name=$(cargo read-manifest | jq -r .name)" >> $GITHUB_OUTPUT
84+
- name: Read version
85+
id: version
86+
run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT
87+
- name: Create release
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions
90+
run: gh release create "${{ steps.version.outputs.version }}" --repo="$GITHUB_REPOSITORY" --title="Release ${{ steps.version.outputs.version }}" --generate-notes --latest "./target/package/${{ steps.crate_name.outputs.crate_name }}-${{ steps.version.outputs.version }}.crate"

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# These are backup files generated by rustfmt
7+
**/*.rs.bk
8+
9+
# MSVC Windows builds of rustc generate these, which store debugging information
10+
*.pdb
11+
12+
13+
# Added by cargo
14+
15+
/target

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix"
3+
}

0 commit comments

Comments
 (0)