diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000..bc49564 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,64 @@ +name: Build and test +on: + pull_request: + branches: [main] +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + env: [ubuntu-64, macos-64, windows-64] + include: + - env: ubuntu-64 + os: ubuntu-latest + toolchain: stable-x86_64-unknown-linux-gnu + - env: macos-64 + os: macos-latest + toolchain: stable-x86_64-apple-darwin + - env: windows-64 + os: windows-latest + toolchain: stable-x86_64-pc-windows-msvc + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup toolchain ${{ matrix.toolchain }} for ${{ matrix.os }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + - name: Build using ${{ matrix.toolchain }} for ${{ matrix.os }} + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --all-features + test: + name: Test + needs: build + runs-on: ${{ matrix.os }} + strategy: + matrix: + env: [ubuntu-64, macos-64, windows-64] + include: + - env: ubuntu-64 + os: ubuntu-latest + toolchain: stable-x86_64-unknown-linux-gnu + - env: macos-64 + os: macos-latest + toolchain: stable-x86_64-apple-darwin + - env: windows-64 + os: windows-latest + toolchain: stable-x86_64-pc-windows-msvc + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Rust toolchain ${{ matrix.toolchain }} for ${{ matrix.os }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + - name: Test using ${{ matrix.toolchain }} for ${{ matrix.os }} + uses: actions-rs/cargo@v1 + with: + command: test + args: --release --all-features diff --git a/.github/workflows/check_version_bump.yml b/.github/workflows/check_version_bump.yml new file mode 100644 index 0000000..28f2460 --- /dev/null +++ b/.github/workflows/check_version_bump.yml @@ -0,0 +1,34 @@ +name: Check version bump +on: + pull_request: + branches: [main] +jobs: + check: + name: Check version bump + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest + uses: actions-rs/toolchain@v1 + with: + toolchain: stable-x86_64-unknown-linux-gnu + override: true + - name: Read branch version + id: branch_version + run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT + - name: Checkout main + uses: actions/checkout@v2 + with: + ref: main + - name: Read main version + id: main_version + run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT + - name: Check version bump + run: | + if [ "${{ steps.branch_version.outputs.version }}" == "${{ steps.main_version.outputs.version }}" ]; then + echo "Missing version bump!" + exit 1 + else + echo "Version was bumped!" + fi diff --git a/.github/workflows/deploy_prerelease.yml b/.github/workflows/deploy_prerelease.yml new file mode 100644 index 0000000..186c05e --- /dev/null +++ b/.github/workflows/deploy_prerelease.yml @@ -0,0 +1,36 @@ +name: Deploy pre-release +on: + push: + branches: [staging] +jobs: + github: + name: Deploy GitHub (pre-release) + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest + uses: actions-rs/toolchain@v1 + with: + toolchain: stable-x86_64-unknown-linux-gnu + override: true + - name: Package + uses: actions-rs/cargo@v1 + with: + command: package + args: --all-features + - name: Read crate name + id: crate_name + run: echo "crate_name=$(cargo read-manifest | jq -r .name)" >> $GITHUB_OUTPUT + - name: Read version + id: version + run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT + - name: Read git commit hash + id: commit_hash + run: echo "commit_hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions + run: gh release create "${{ steps.commit_hash.outputs.commit_hash }}" --repo="$GITHUB_REPOSITORY" --target staging --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" diff --git a/.github/workflows/deploy_release.yml b/.github/workflows/deploy_release.yml new file mode 100644 index 0000000..48481c5 --- /dev/null +++ b/.github/workflows/deploy_release.yml @@ -0,0 +1,54 @@ +name: Deploy release +on: + push: + branches: [main] +jobs: + crates_io: + name: Deploy crates.io (release) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest + uses: actions-rs/toolchain@v1 + with: + toolchain: stable-x86_64-unknown-linux-gnu + override: true + - name: Login to crates.io + uses: actions-rs/cargo@v1 + with: + command: login + args: ${{ secrets.CRATES_IO_TOKEN }} + - name: Publish to crates.io + uses: actions-rs/cargo@v1 + with: + command: publish + github: + name: Deploy GitHub (release) + needs: crates_io + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Rust toolchain stable-x86_64-unknown-linux-gnu for ubuntu-latest + uses: actions-rs/toolchain@v1 + with: + toolchain: stable-x86_64-unknown-linux-gnu + override: true + - name: Package + uses: actions-rs/cargo@v1 + with: + command: package + args: --all-features + - name: Read crate name + id: crate_name + run: echo "crate_name=$(cargo read-manifest | jq -r .name)" >> $GITHUB_OUTPUT + - name: Read version + id: version + run: echo "version=$(cargo read-manifest | jq -r .version)" >> $GITHUB_OUTPUT + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions + 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" diff --git a/.gitignore b/.gitignore index 6985cf1..196e176 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,8 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + + +# Added by cargo + +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..d39ef20 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "lum" +version = "0.1.0" +edition = "2021" +description = "Lum Discord Bot" +license= "MIT" +readme = "README.md" +authors = ["Torben Schweren"] +repository = "https://github.com/Kitt3120/lum" + + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = { version = "1.0.193", features = ["derive"] } +serde_json = "1.0.108" +sqlx = { version = "0.7.3", features = ["runtime-tokio", "any", "postgres", "mysql", "sqlite", "tls-native-tls", "migrate", "macros", "uuid", "chrono", "json"] } +tokio = { version = "1.35.1", features = ["full"] } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..7609593 --- /dev/null +++ b/build.rs @@ -0,0 +1,5 @@ +// generated by `sqlx migrate build-script` +fn main() { + // trigger recompilation when a new migration is added + println!("cargo:rerun-if-changed=migrations"); +} \ No newline at end of file diff --git a/migrations/0001_init.sql b/migrations/0001_init.sql new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}