diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e2718b..78ee61a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,9 @@ name: Cargo Release on: - workflow_dispatch: + push: + tags: + - 'v*.*.*' jobs: release: @@ -11,16 +13,28 @@ jobs: contents: write id-token: write steps: - - uses: actions/checkout@v5 - - run: | - git config --local user.name "GitHub Actions" - git config --local user.email "actions@github.com" + - uses: actions/checkout@v4 + with: + ref: main - - name: Install cargo release - run: cargo install cargo-release + - name: Extract version from tag + run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" + + - name: Update Cargo.toml version + run: sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml + + - name: Commit version bump + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add Cargo.toml + git commit -m "chore: bump version to $VERSION" + git push origin main - uses: rust-lang/crates-io-auth-action@v1 id: auth - - run: cargo release patch --execute --no-confirm + + - name: Publish to crates.io + run: cargo publish env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c3dd78b..3584523 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v4 - name: Cache uses: actions/cache@v4 @@ -25,6 +25,8 @@ jobs: ~/.cargo/git target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- - name: Build run: cargo build --verbose diff --git a/examples/tetris/src/field.rs b/examples/tetris/src/field.rs index 19e60e2..1c81318 100644 --- a/examples/tetris/src/field.rs +++ b/examples/tetris/src/field.rs @@ -67,6 +67,7 @@ impl FieldExt for Field { false } + #[allow(clippy::needless_range_loop)] fn is_gameover(&self) -> bool { for x in 0..FIELD_WIDTH { if self[FIELD_MARGIN][x].is_some() {