From 0aa76e11d2156f90ce57be843066eb4ecddb6e14 Mon Sep 17 00:00:00 2001 From: Pedro Nauck Date: Thu, 6 Jun 2024 20:24:15 -0300 Subject: [PATCH] ci: improve/fix release action Now, on each push on master, a new stable release is made following semver using commit logs with Knope --- .changeset/.gitkeep | 0 clippy.toml => .clippy.toml | 0 .commitlintrc.yaml | 1 + .cz.toml | 7 -- .github/workflows/ci.yaml | 58 ++++++---- .github/workflows/prepare_release.yaml | 71 ++++++++++++ .github/workflows/release.yaml | 149 +++++++++---------------- .github/workflows/update_deps.yaml | 2 +- .gitignore | 1 + .pre-commit-config.yaml | 64 ++++++----- .rustfmt.toml | 9 +- CONTRIBUTING.md | 82 ++++++-------- Cargo.lock | 4 + Cargo.toml | 4 + Makefile | 109 +++++++++++++++--- crates/nats-stream/src/main.rs | 2 +- knope.toml | 87 +++++++++++++++ scripts/bump-version.sh | 5 + scripts/setup.sh | 9 +- src/main.rs | 3 + 20 files changed, 439 insertions(+), 228 deletions(-) create mode 100644 .changeset/.gitkeep rename clippy.toml => .clippy.toml (100%) create mode 100644 .commitlintrc.yaml delete mode 100644 .cz.toml create mode 100644 .github/workflows/prepare_release.yaml create mode 100644 knope.toml create mode 100755 scripts/bump-version.sh create mode 100644 src/main.rs diff --git a/.changeset/.gitkeep b/.changeset/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/clippy.toml b/.clippy.toml similarity index 100% rename from clippy.toml rename to .clippy.toml diff --git a/.commitlintrc.yaml b/.commitlintrc.yaml new file mode 100644 index 0000000..28fbce6 --- /dev/null +++ b/.commitlintrc.yaml @@ -0,0 +1 @@ +extends: ['@commitlint/config-conventional'] diff --git a/.cz.toml b/.cz.toml deleted file mode 100644 index 5ac0af5..0000000 --- a/.cz.toml +++ /dev/null @@ -1,7 +0,0 @@ -[tool.commitizen] -name = "cz_conventional_commits" -tag_format = "$version" -version_scheme = "semver" -version_provider = "cargo" -update_changelog_on_bump = true -major_version_zero = true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e473f73..7700d41 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,11 +1,8 @@ name: CI -permissions: - contents: read - on: pull_request: - types: [opened, synchronize, edited, closed, reopened] + types: [opened, synchronize, edited, reopened] env: CARGO_TERM_COLOR: always @@ -17,11 +14,11 @@ concurrency: cancel-in-progress: true jobs: - validate-itle: + validate-title: name: Validate PR Title runs-on: ubuntu-latest steps: - - uses: amannn/action-semantic-pull-request@v4 + - uses: amannn/action-semantic-pull-request@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -35,28 +32,41 @@ jobs: with: toolchain: stable - uses: Swatinem/rust-cache@v2 - - name: Is lockfile updated? - run: cargo update --workspace --locked + - run: cargo update --workspace --locked - clippy: - name: Clippy + lint: + name: Linting + if: "!startsWith(github.head_ref, 'releases/')" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Install Rust - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@nightly with: - toolchain: ${{ env.RUST_VERSION }} - components: clippy - - uses: Swatinem/rust-cache@v2 - - run: cargo clippy --all-targets --all-features + components: clippy, rustfmt - pre-commit: - name: Linting & Formatting - permissions: - contents: read - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - - uses: pre-commit/action@v3.0.1 + - name: Cache Rust toolchain + uses: actions/cache@v3 + with: + path: | + ~/.rustup + ~/.cargo/bin + key: ${{ runner.os }}-rust-toolchain + + - name: Cache Cargo dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-deps-${{ hashFiles('**/Cargo.lock') }} + + - name: Install dependencies + uses: taiki-e/install-action@v2 + with: + tool: cargo-sort@1.0.9 + + - name: Running linting + run: make lint diff --git a/.github/workflows/prepare_release.yaml b/.github/workflows/prepare_release.yaml new file mode 100644 index 0000000..861011e --- /dev/null +++ b/.github/workflows/prepare_release.yaml @@ -0,0 +1,71 @@ +name: Open Release PR + +on: + push: + branches: [main, staging, release] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + CLICOLOR: 1 + RUST_VERSION: 1.78.0 + +jobs: + setup: + if: "!startsWith(github.event.head_commit.message, 'ci(bump)')" + runs-on: ubuntu-latest + outputs: + branch: ${{ steps.set-vars.outputs.branch }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Check for pre-release configuration + id: set-vars + run: | + echo "branch=changeset/release-main" >> $GITHUB_OUTPUT + + prepare-release: + if: "!startsWith(github.event.head_commit.message, 'ci(bump)')" + needs: setup + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.REPO_TOKEN }} + + - name: Configure Git + run: | + git config --global user.name GitHub Actions + git config user.email github-actions@github.com + + - name: Cache Rust dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - run: rustup toolchain install nightly -c rustfmt + - uses: taiki-e/install-action@v2 + with: + tool: cargo-sort@1.0.9, cargo-edit@0.12.3 + + - uses: knope-dev/action@v2.1.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run knope prepare release + env: + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} + RELEASE_BRANCH: ${{ needs.setup.outputs.branch }} + run: knope prepare-release --verbose diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bed4b99..5fdaee3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,121 +1,72 @@ name: Release on: - push: - branches: [main, staging, release] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + pull_request: + types: [closed] + branches: [main] jobs: - setup: - runs-on: ubuntu-latest - outputs: - prerelease: ${{ steps.set-prerelease.outputs.prerelease }} + build-artifacts: + env: + archive_name: artifact - steps: - - name: Checkout code - uses: actions/checkout@v4 + strategy: + fail-fast: false + matrix: + pkg: [fuel-nats-stream] + os: [ubuntu-latest] + target: [x86_64-unknown-linux-gnu] - - name: Setup git user (for changelog step) - run: | - git config --global user.name "${{ github.actor }}" - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - - name: Check for pre-release configuration - id: set-prerelease - run: | - if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then - echo "prerelease=nightly" >> $GITHUB_OUTPUT - elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then - echo "prerelease=rc" >> $GITHUB_OUTPUT - else - echo "prerelease=false" >> $GITHUB_OUTPUT - - changelog: - runs-on: ubuntu-latest - needs: setup - outputs: - version: ${{ steps.save-outputs.outputs.version }} - changelog: ${{ steps.save-outputs.outputs.changelog }} - commit_message: ${{ steps.save-outputs.outputs.commit_message }} - branch: ${{ steps.save-outputs.outputs.branch }} + runs-on: ${{ matrix.os }} + name: ${{ matrix.pkg }} ${{ matrix.target }} steps: - - name: Checkout code - uses: actions/checkout@v4 - - - id: cz - name: Create bump and changelog - uses: commitizen-tools/commitizen-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - changelog_increment_filename: body.md - prerelease: ${{ needs.setup.outputs.prerelease }} + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 - - name: Save outputs - id: save-outputs - run: | - version=${{ steps.cz.outputs.version }} - changelog=$(cat body.md) - commit_message="ci(bump): release ${version}" - branch="release-${{ steps.cz.outputs.version }}" + - name: Install host target + run: rustup target add ${{ matrix.target }} - echo "version=${version}" >> $GITHUB_OUTPUT - echo "changelog=${changelog}" >> $GITHUB_OUTPUT - echo "commit_message=${commit_message}" >> $GITHUB_OUTPUT - echo "branch=${branch}" >> $GITHUB_OUTPUT + - name: Build + run: make build TARGET=${{ matrix.target }} PACKAGE=${{ matrix.pkg }} - create_pr: - runs-on: ubuntu-latest - needs: changelog + - name: Set Archive Name + id: archive + run: echo "archive_name=${{ matrix.pkg }}-${{ matrix.target }}" >> $GITHUB_ENV - steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Create Tar Archive + run: | + mkdir ${{ env.archive_name }} + cp target/${{ matrix.target }}/release/${{ matrix.pkg }} ${{ env.archive_name }} + tar -czf ${{ env.archive_name }}.tgz ${{ env.archive_name }} - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v3 + - name: Upload Artifact + uses: actions/upload-artifact@v4.3.3 with: - commit-message: ${{ needs.changelog.outputs.commit_message }} - title: Release ${{ needs.changelog.outputs.version }} - body: | - ${{ needs.changelog.outputs.changelog }} - branch: ${{ needs.changelog.outputs.branch }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Check outputs - if: ${{ steps.cpr.outputs.pull-request-number }} - run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + name: ${{ matrix.pkg }}-${{ matrix.target }} + path: ${{ env.archive_name }}.tgz + if-no-files-found: error release: + needs: [build-artifacts] runs-on: ubuntu-latest - needs: changelog - if: github.ref == 'refs/heads/release' - + permissions: + contents: read + actions: write steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Release - uses: softprops/action-gh-release@v1 + - uses: actions/checkout@v4.1.6 + - uses: actions/download-artifact@v4.1.7 with: - body_path: body.md - tag_name: ${{ needs.changelog.outputs.version }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + path: artifacts + merge-multiple: true - notify: - runs-on: ubuntu-latest - if: failure() + - name: List artifacts + run: ls -R artifacts - steps: - - name: Error Notification - run: |- - echo "An error occurred during the release process" - # Optionally, send a notification to Slack or email + - uses: knope-dev/action@v2.1.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - run: knope release + env: + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} diff --git a/.github/workflows/update_deps.yaml b/.github/workflows/update_deps.yaml index d1f2023..37a2ecb 100644 --- a/.github/workflows/update_deps.yaml +++ b/.github/workflows/update_deps.yaml @@ -95,7 +95,7 @@ jobs: git commit --no-verify --file=commit.txt - name: Create or Update Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v6 with: commit-message: ${{ env.COMMIT_MESSAGE }} title: ${{ env.PR_TITLE }} diff --git a/.gitignore b/.gitignore index 3d14346..16b395a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ lcov.info node_modules/ pnpm-lock.yaml ./package.json +tmp diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ec6276..a697b51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,38 +1,18 @@ -exclude: | - (?x)^( - tests/.*| - CHANGELOG.md - )$ +default_install_hook_types: [pre-commit, pre-push, commit-msg] +default_stages: [pre-commit] repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: - id: trailing-whitespace - stages: [commit] - id: end-of-file-fixer - stages: [commit] - - id: check-yaml - stages: [commit] - id: check-json - stages: [commit] - id: check-toml - stages: [commit] - id: check-added-large-files - stages: [commit] - id: check-merge-conflict - stages: [commit] - id: check-case-conflict - stages: [commit] - id: detect-private-key - stages: [commit] - - - repo: https://github.com/commitizen-tools/commitizen - rev: v3.27.0 - hooks: - - id: commitizen - - id: commitizen-branch - stages: [push] - repo: https://github.com/lyz-code/yamlfix/ rev: 1.16.0 @@ -40,16 +20,44 @@ repos: - id: yamlfix args: [-c, .yamlfix.toml] + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.16.0 + hooks: + - id: commitlint + stages: [commit-msg] + additional_dependencies: ['@commitlint/config-conventional'] + - repo: https://github.com/crate-ci/typos rev: v1.21.0 hooks: - id: typos - - repo: https://github.com/doublify/pre-commit-rust - rev: v1.0 + - repo: local hooks: - - id: fmt - args: [--, --check, --color, always] - id: clippy - args: [--all-targets, --all-features, --, -D, warnings] - stages: [manual] + name: clippy + description: Lint rust sources + entry: make lint-clippy + language: system + types: [rust] + pass_filenames: false + - id: fmt-markdown + name: lint-markdown + description: Lint config files using Prettier + entry: npx prettier --write --no-error-on-unmatched-pattern + language: system + types: [markdown] + - id: fmt-rust + name: fmt-rust + description: Format files with cargo fmt. + entry: make fmt-rust + language: system + types: [rust] + pass_filenames: false + - id: fmt-cargo + name: fmt-cargo + description: Lint Cargo.toml files using cargo-sort + entry: make fmt-cargo + language: system + types: [toml] + pass_filenames: false diff --git a/.rustfmt.toml b/.rustfmt.toml index cbce36b..b45980f 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,6 +1,9 @@ -max_width = 100 -edition = "2021" +max_width = 90 +normalize_comments = true +imports_layout = "Vertical" +imports_granularity = "Crate" +trailing_semicolon = false use_try_shorthand = true +edition = "2021" use_field_init_shorthand = true -hard_tabs = true tab_spaces = 4 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5eaa29e..109b232 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,9 +9,10 @@ Most projects under the umbrella of data systems are written in Rust, so we prefer using Rust tooling and community standards. Ensure you have the following tools installed: -- [Rust](https://www.rust-lang.org/tools/install) -- [Make](https://www.gnu.org/software/make/) -- [Pre-commit](https://pre-commit.com/#install) +- [Rust](https://www.rust-lang.org/tools/install) +- [Make](https://www.gnu.org/software/make/) +- [Pre-commit](https://pre-commit.com/#install) +- [NodeJS](https://nodejs.org/en/download/) ## 📟 Setting up @@ -37,12 +38,10 @@ being installed on your machine. We enforce some conventions to ensure code quality, sustainability, and maintainability. The following tools help us with that: -- [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) - - Ensures that commit messages are clear and understandable. -- [Pre-commit](https://pre-commit.com/) - Ensures that the code is formatted - and linted before being committed. -- [Commitizen](https://commitizen-tools.github.io/commitizen/) - Standardizes - commit messages using the Conventional Commits specification. +- [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) - + Ensures that commit messages are clear and understandable. +- [Pre-commit](https://pre-commit.com/) - Ensures that the code is formatted + and linted before being committed. ### Writing your commits @@ -51,52 +50,37 @@ Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. Use `category(scope or module): message` in your commit message with one of the following categories: -- `feat / feature`: All changes that introduce completely new code or new - features. -- `fix`: Changes that fix a bug (ideally referencing an issue if present). -- `refactor`: Any code-related change that is not a fix or a feature. -- `docs`: Changes to existing documentation or creation of new documentation - (e.g., README, usage docs). -- `build`: Changes regarding the build of the software, dependencies, or the - addition of new dependencies. -- `test`: Changes regarding tests (adding new tests or changing existing - ones). -- `ci`: Changes regarding the configuration of continuous integration (e.g., - GitHub Actions, CI systems). -- `chore`: Changes to the repository that do not fit into any of the above - categories. - -### Using Commitizen - -Commitizen helps you create commit messages that follow the Conventional -Commits specification. To use Commitizen, refer to the [Commitizen installation -guide](https://commitizen-tools.github.io/commitizen/). - -Once installed, create your commit using the following command: - -```sh -cz commit -``` - -Commitizen will guide you through the process of creating a standardized -commit message. +- `feat`: All changes that introduce completely new code or new + features. +- `fix`: Changes that fix a bug (ideally referencing an issue if present). +- `refactor`: Any code-related change that is not a fix or a feature. +- `docs`: Changes to existing documentation or creation of new documentation + (e.g., README, usage docs). +- `build`: Changes regarding the build of the software, dependencies, or the + addition of new dependencies. +- `test`: Changes regarding tests (adding new tests or changing existing + ones). +- `ci`: Changes regarding the configuration of continuous integration (e.g., + GitHub Actions, CI systems). +- `chore`: Changes to the repository that do not fit into any of the above + categories. ## 📜 Useful Commands To make your life easier, here are some commands to run common tasks in this project: -| Command | Description | -| ---------------- | ------------------------------------------------------ | -| `make build` | Build the project | -| `make check` | Run cargo check | -| `make dev-watch` | Run the project in development mode with auto-reload | -| `make dev` | Run the project in development mode | -| `make fmt` | Format the code | -| `make install` | Install the project | -| `make lint` | Format and lint the code | -| `make run` | Run the project in release mode | -| `make setup` | Install all the tools needed | +| Command | Description | +| ---------------- | ----------------------------------------------------- | +| `make build` | Build the project with default settings | +| `make clean` | Clean the build artifacts and release directory | +| `make dev-watch` | Run the project in development mode with auto-reload | +| `make dev` | Run the project in development mode | +| `make fmt` | Format the code and Markdown files | +| `make install` | Fetch the project dependencies using `cargo fetch` | +| `make lint` | Perform linting checks on the code and Markdown files | +| `make run` | Run the built executable using `cargo run --release` | +| `make setup` | Run the setup script located at `./scripts/setup.sh` | ## 📬 Open a Pull Request diff --git a/Cargo.lock b/Cargo.lock index 2743734..e26fbec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1227,6 +1227,10 @@ dependencies = [ "sha2", ] +[[package]] +name = "fuel-nats" +version = "0.0.1" + [[package]] name = "fuel-nats-stream" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index a0a17c2..f872cc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,7 @@ +[package] +name = "fuel-nats" +version = "0.0.1" + [workspace] members = ["crates/nats-stream"] resolver = "2" diff --git a/Makefile b/Makefile index adcf404..a653ee9 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,23 @@ -build: - cargo build --release +# ------------------------------------------------------------ +# Setup +# ------------------------------------------------------------ -check: - cargo check --all-targets --all-features +TARGET ?= aarch64-apple-darwin +PACKAGE ?= fuel-nats-stream + +.PHONY: all build run clean lint fmt help test doc + +all: build + +install: + cargo fetch + +setup: + ./scripts/setup.sh + +# ------------------------------------------------------------ +# Development +# ------------------------------------------------------------ dev: cargo run @@ -10,18 +25,84 @@ dev: dev-watch: cargo watch -- cargo run -fmt: - cargo fmt -- --check --color always - -install: - cargo fetch +# ------------------------------------------------------------ +# Build & Release +# ------------------------------------------------------------ -lint: - pre-commit run --all-files - pre-commit run --hook-stage manual clippy --all-files +build: install + cargo build --release --target "$(TARGET)" --package "$(PACKAGE)" run: cargo run --release -setup: - ./scripts/install.sh +clean: + cargo clean + rm -rf release + +# ------------------------------------------------------------ +# Format +# ------------------------------------------------------------ + +fmt: fmt-cargo fmt-rust fmt-markdown + +fmt-cargo: + cargo sort -w + +fmt-rust: + cargo +nightly fmt -- --color always + +fmt-markdown: + npx prettier *.md **/*.md --write --no-error-on-unmatched-pattern + +# ------------------------------------------------------------ +# Validate code +# ------------------------------------------------------------ + +check: + cargo check --all-targets --all-features + +lint: check lint-cargo lint-rust lint-clippy lint-markdown + +lint-cargo: + cargo sort -w --check + +lint-rust: + cargo +nightly fmt -- --check --color always + +lint-clippy: + cargo clippy --workspace -- -D warnings + +lint-markdown: + npx prettier *.md **/*.md --check --no-error-on-unmatched-pattern + +# ------------------------------------------------------------ +# Test +# ------------------------------------------------------------ + +test: + cargo test --all + +# ------------------------------------------------------------ +# Documentation +# ------------------------------------------------------------ + +doc: + cargo doc --no-deps + +# ------------------------------------------------------------ +# Help +# ------------------------------------------------------------ + +help: + @echo "Available commands:" + @echo " install - Install project dependencies" + @echo " setup - Run the setup script" + @echo " dev - Run the project in development mode" + @echo " dev-watch - Run the project in development mode with auto-reload" + @echo " build - Build the project" + @echo " run - Run the project in release mode" + @echo " clean - Clean the build artifacts and release directory" + @echo " fmt - Format the code and Markdown files" + @echo " lint - Perform linting checks on the code and Markdown files" + @echo " test - Run tests" + @echo " doc - Generate documentation" diff --git a/crates/nats-stream/src/main.rs b/crates/nats-stream/src/main.rs index a30eb95..e7a11a9 100644 --- a/crates/nats-stream/src/main.rs +++ b/crates/nats-stream/src/main.rs @@ -1,3 +1,3 @@ fn main() { - println!("Hello, world!"); + println!("Hello, world!"); } diff --git a/knope.toml b/knope.toml new file mode 100644 index 0000000..f138aef --- /dev/null +++ b/knope.toml @@ -0,0 +1,87 @@ +[package] +versioned_files = ["Cargo.toml"] +changelog = "CHANGELOG.md" + +[[package.assets]] +path = "artifacts/fuel-nats-stream-x86_64-unknown-linux-gnu.tgz" + +# ------------------------------------------------------------ +# Workflow to get the current version +# ------------------------------------------------------------ +[[workflows]] +name = "get-version" +help_text = "Get the current version of the project" + +[[workflows.steps]] +type = "Command" +command = "echo \"$VERSION\"" +variables = { "$VERSION" = "Version" } + +# ------------------------------------------------------------ +# Workflow to create a new changeset +# ------------------------------------------------------------ +[[workflows]] +name = "changeset" + +[[workflows.steps]] +type = "CreateChangeFile" + +# ------------------------------------------------------------ +# Workflow to create a new release +# ------------------------------------------------------------ +[[workflows]] +name = "prepare-release" + +[[workflows.steps]] +type = "PrepareRelease" + +[[workflows.steps]] +type = "Command" +command = "git switch -c $RELEASE_BRANCH" +shell = true + +[[workflows.steps]] +type = "Command" +command = "./scripts/bump-version.sh $VERSION && git add ." +variables = { "$VERSION" = "Version" } +shell = true + +[[workflows.steps]] +type = "Command" +command = "git commit -m \"ci(bump): prepare release $VERSION\"" +variables = { "$VERSION" = "Version" } + +[[workflows.steps]] +type = "Command" +command = "git push --force --set-upstream origin $RELEASE_BRANCH" +shell = true + +[[workflows.steps]] +type = "CreatePullRequest" +base = "main" +variables = { "$VERSION" = "Version" } + +[workflows.steps.title] +template = "ci(bump): prepare release $VERSION" +variables = { "$VERSION" = "Version" } + +[workflows.steps.body] +template = "v$VERSION" +variables = { "$VERSION" = "Version" } + +# ------------------------------------------------------------ +# Workflow to release a new version +# ------------------------------------------------------------ +[[workflows]] +name = "release" + +[[workflows.steps]] +type = "Release" +variables = { "$VERSION" = "Version" } + +# ------------------------------------------------------------ +# GitHub configuration +# ------------------------------------------------------------ +[github] +owner = "fuellabs" +repo = "data-systems" diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh new file mode 100755 index 0000000..86bf2c8 --- /dev/null +++ b/scripts/bump-version.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cargo set-version --workspace "$1" +cargo update --workspace +make fmt diff --git a/scripts/setup.sh b/scripts/setup.sh index 91742e8..331a008 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -15,5 +15,10 @@ check_command pre-commit # Install pre-commit hooks pre-commit install -# Install cargo watch -cargo install cargo-watch + +# Install nightly toolchain +rustup toolchain install nightly -c rustfmt + +# Install cargo global crates +cargo install cargo-binstall +cargo binstall --no-confirm cargo-watch knope cargo-sort 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!"); +}