Skip to content

Commit 3bef2c7

Browse files
chore: set release-plz CI (#110)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9552ce3 commit 3bef2c7

File tree

7 files changed

+78
-49
lines changed

7 files changed

+78
-49
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ jobs:
2323
uses: Swatinem/rust-cache@v2
2424
- uses: taiki-e/install-action@v2
2525
with: { tool: just }
26-
- name: Ensure this crate has not yet been published
27-
run: just check-if-published
2826
- run: just ci-test
29-
- name: Check semver
30-
uses: obi1kenobi/cargo-semver-checks-action@v2
3127

3228
test-msrv:
3329
name: Test MSRV
@@ -199,16 +195,3 @@ jobs:
199195
steps:
200196
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
201197
run: exit 1
202-
203-
release:
204-
# Some dependencies of the `ci-passed` job might be skipped, but we still want to run if the `ci-passed` job succeeded.
205-
if: always() && startsWith(github.ref, 'refs/tags/') && needs.ci-passed.result == 'success'
206-
name: Publish to crates.io
207-
needs: [ ci-passed ]
208-
runs-on: ubuntu-latest
209-
steps:
210-
- uses: actions/checkout@v4
211-
- name: Publish to crates.io
212-
run: cargo publish
213-
env:
214-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/release-plz.yml

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

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ repos:
1919
args: [ --fix=lf ]
2020
- id: trailing-whitespace
2121

22+
- repo: https://github.com/Lucas-C/pre-commit-hooks
23+
rev: v1.5.5
24+
hooks:
25+
- id: forbid-tabs
26+
- id: remove-tabs
27+
2228
- repo: local
2329
hooks:
2430
- id: cargo-fmt

Cargo.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE-APACHE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.
193193
You may obtain a copy of the License at
194194

195-
http://www.apache.org/licenses/LICENSE-2.0
195+
http://www.apache.org/licenses/LICENSE-2.0
196196

197197
Unless required by applicable law or agreed to in writing, software
198198
distributed under the License is distributed on an "AS IS" BASIS,

justfile

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,6 @@ build-lib:
4040
check:
4141
cargo check --workspace --all-targets {{features_flag}}
4242

43-
# Verify that the current version of the crate is not the same as the one published on crates.io
44-
check-if-published package=main_crate:
45-
#!/usr/bin/env bash
46-
set -euo pipefail
47-
LOCAL_VERSION="$({{just_executable()}} get-crate-field version {{package}})"
48-
echo "Detected crate {{package}} version: '$LOCAL_VERSION'"
49-
PUBLISHED_VERSION="$(cargo search --quiet {{package}} | grep "^{{package}} =" | sed -E 's/.* = "(.*)".*/\1/')"
50-
echo "Published crate version: '$PUBLISHED_VERSION'"
51-
if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
52-
echo "ERROR: The current crate version has already been published."
53-
exit 1
54-
else
55-
echo "The current crate version has not yet been published."
56-
fi
57-
5843
# Quick compile - lib-only
5944
check-lib:
6045
cargo check --workspace
@@ -116,6 +101,7 @@ env-info:
116101
rustup --version
117102
@echo "RUSTFLAGS='$RUSTFLAGS'"
118103
@echo "RUSTDOCFLAGS='$RUSTDOCFLAGS'"
104+
@echo "RUST_BACKTRACE='$RUST_BACKTRACE'"
119105

120106
# Reformat all code `cargo fmt`. If nightly is available, use it for better results
121107
fmt:
@@ -140,6 +126,9 @@ get-msrv package=main_crate: (get-crate-field 'rust_version' package)
140126
msrv: (cargo-install 'cargo-msrv')
141127
cargo msrv find --write-msrv --ignore-lockfile
142128

129+
release *args='': (cargo-install 'release-plz')
130+
release-plz {{args}}
131+
143132
# Check semver compatibility with prior published version. Install it with `cargo install cargo-semver-checks`
144133
semver *args: (cargo-install 'cargo-semver-checks')
145134
cargo semver-checks {{features_flag}} {{args}}

release-plz.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[workspace]
2+
git_release_name = "v{{ version }}"
3+
git_tag_name = "v{{ version }}"

0 commit comments

Comments
 (0)