Skip to content

Commit 414478e

Browse files
authored
ci(release): add release bot (#346)
Refs: #340
1 parent 0427669 commit 414478e

File tree

6 files changed

+214
-18
lines changed

6 files changed

+214
-18
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
# Check for updates every Monday
6+
schedule:
7+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,75 @@ on:
77
branches:
88
- master
99
pull_request:
10+
env:
11+
# increment this manually to force cache eviction
12+
RUST_CACHE_PREFIX: "v0-rust"
1013

1114
jobs:
15+
lint:
16+
name: Lint
17+
runs-on: ubuntu-latest
18+
env:
19+
clang: "17"
20+
php_version: "8.2"
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
- name: Check typos
27+
uses: crate-ci/typos@master
28+
- name: Validate commit messages
29+
run: |
30+
git show-ref
31+
curl -sSfL https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip | zcat > convco
32+
chmod +x convco
33+
./convco check refs/remotes/origin/master..HEAD
34+
rm convco
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ env.php_version }}
39+
env:
40+
debug: true
41+
- name: Setup Rust
42+
uses: dtolnay/rust-toolchain@master
43+
with:
44+
components: rustfmt, clippy
45+
toolchain: stable
46+
- name: Cache cargo dependencies
47+
uses: Swatinem/rust-cache@v2
48+
with:
49+
prefix-key: ${{ env.RUST_CACHE_PREFIX }}
50+
- name: Cache LLVM and Clang
51+
id: cache-llvm
52+
uses: actions/cache@v3
53+
with:
54+
path: ${{ runner.temp }}/llvm-${{ env.clang }}
55+
key: ubuntu-latest-llvm-${{ env.clang }}
56+
- name: Setup LLVM & Clang
57+
id: clang
58+
uses: KyleMayes/install-llvm-action@v2
59+
with:
60+
version: ${{ env.clang }}
61+
directory: ${{ runner.temp }}/llvm-${{ env.clang }}
62+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
63+
- name: Configure Clang
64+
run: |
65+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
66+
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
67+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/bin/llvm-config" >> $GITHUB_ENV
68+
- name: Run rustfmt
69+
run: cargo fmt --all -- --check
70+
- name: Run clippy
71+
run: cargo clippy --all -- -D warnings
72+
# Docs
73+
- name: Run rustdoc
74+
run: cargo rustdoc -- -D warnings
75+
- name: Build with docs stub
76+
env:
77+
DOCS_RS: ""
78+
run: cargo clean && cargo build
1279
build:
1380
name: Build and Test
1481
runs-on: ${{ matrix.os }}
@@ -59,7 +126,7 @@ jobs:
59126
# if: matrix.rust == 'stable'
60127
with:
61128
# increment this manually to force cache eviction
62-
prefix-key: "v0-rust"
129+
prefix-key: ${{ env.RUST_CACHE_PREFIX }}
63130
# LLVM & Clang
64131
- name: Cache LLVM and Clang
65132
id: cache-llvm
@@ -77,6 +144,7 @@ jobs:
77144
with:
78145
version: ${{ matrix.clang }}
79146
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
147+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
80148
- name: Configure Clang
81149
# Macos build doesn't work with clang < 18. As a build for version 18 is not available, we skip the setup
82150
if: "!contains(matrix.os, 'windows') && !contains(matrix.os, 'macos')"
@@ -89,24 +157,9 @@ jobs:
89157
env:
90158
EXT_PHP_RS_TEST: ""
91159
run: cargo build --release --features closure,anyhow --all
92-
# Test & lint
160+
# Test
93161
- name: Test inline examples
94162
run: cargo test --release --all --features closure,anyhow --no-fail-fast
95-
- name: Run rustfmt
96-
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
97-
run: cargo fmt --all -- --check
98-
- name: Run clippy
99-
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
100-
run: cargo clippy --all -- -D warnings
101-
# Docs
102-
- name: Run rustdoc
103-
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
104-
run: cargo rustdoc -- -D warnings
105-
- name: Build with docs stub
106-
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
107-
env:
108-
DOCS_RS: ""
109-
run: cargo clean && cargo build
110163
build-zts:
111164
name: Build with ZTS
112165
runs-on: ubuntu-latest

.github/workflows/release-plz.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release-plz
2+
3+
permissions:
4+
pull-requests: write
5+
contents: write
6+
7+
on:
8+
workflow_run:
9+
workflows: ["Build and Lint"]
10+
branches: ["master"]
11+
types:
12+
- completed
13+
14+
jobs:
15+
release-plz-release:
16+
name: Release-plz release
17+
runs-on: ubuntu-latest
18+
env:
19+
clang: '17'
20+
php_version: '8.2'
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ env.php_version }}
30+
env:
31+
debug: true
32+
- name: Install Rust toolchain
33+
uses: dtolnay/rust-toolchain@stable
34+
- name: Cache LLVM and Clang
35+
id: cache-llvm
36+
uses: actions/cache@v3
37+
with:
38+
path: ${{ runner.temp }}/llvm-${{ env.clang }}
39+
key: ubuntu-latest-llvm-${{ env.clang }}
40+
- name: Setup LLVM & Clang
41+
id: clang
42+
uses: KyleMayes/install-llvm-action@v2
43+
with:
44+
version: ${{ env.clang }}
45+
directory: ${{ runner.temp }}/llvm-${{ env.clang }}
46+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
47+
- name: Configure Clang
48+
run: |
49+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
50+
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
51+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/bin/llvm-config" >> $GITHUB_ENV
52+
- name: Run release-plz
53+
uses: release-plz/[email protected]
54+
with:
55+
command: release
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
58+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
59+
60+
release-plz-pr:
61+
name: Release-plz PR
62+
runs-on: ubuntu-latest
63+
concurrency:
64+
group: release-plz-${{ github.ref }}
65+
cancel-in-progress: false
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v4
69+
with:
70+
fetch-depth: 0
71+
- name: Install Rust toolchain
72+
uses: dtolnay/rust-toolchain@stable
73+
- name: Run release-plz
74+
uses: release-plz/[email protected]
75+
with:
76+
command: release-pr
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
79+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.release-plz.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[workspace]
2+
release_always = false
3+
publish_all_features = true
4+
git_release_body = """
5+
{{ changelog }}
6+
{% if remote.contributors %}
7+
### Thanks to the contributors for this release:
8+
{% for contributor in remote.contributors %}
9+
* @{{ contributor.username }}
10+
{% endfor %}
11+
{% endif %}
12+
"""
13+
14+
[changelog]
15+
header = "# Changelog"
16+
body = """
17+
{%- macro username(commit) -%}
18+
{% if commit.remote.username %} (by @{{ commit.remote.username }}){% endif -%}
19+
{% endmacro -%}
20+
{% macro commit_message(commit) %}
21+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
22+
{% if commit.breaking %}[**breaking**] {% endif %}\
23+
{{ commit.message | upper_first }}\
24+
{{ self::username(commit=commit) }} \
25+
{%- if commit.links %} \
26+
{% for link in commit.links | unique(attribute="href") %}\
27+
[[{{link.text}}]({{link.href}})] \
28+
{% endfor %}\
29+
{% endif %}
30+
{%- if commit.breaking and commit.breaking_description and not commit.breaking_description == commit.message%}
31+
> {{ commit.breaking_description -}}
32+
{% endif -%}
33+
{% endmacro %}
34+
## [{{ version | trim_start_matches(pat="v") }}]{%- if release_link -%}({{ release_link }}){% endif %} - {{ timestamp | date(format="%Y-%m-%d") -}}
35+
{%- for group, commits in commits | group_by(attribute="group") %}
36+
37+
### {{ group | upper_first -}}
38+
{% for commit in commits
39+
| filter(attribute="scope")
40+
| sort(attribute="scope") -%}
41+
{{- self::commit_message(commit=commit) -}}
42+
{% endfor -%}
43+
{%- for commit in commits -%}
44+
{% if not commit.scope -%}
45+
{{- self::commit_message(commit=commit) -}}
46+
{% endif -%}
47+
{% endfor -%}
48+
{% endfor %}
49+
"""
50+
link_parsers = [
51+
{ pattern = "#(\\d+)", href = "https://github.com/davidcole1340/ext-php-rs/issues/$1" },
52+
]

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ Contributions welcome include:
189189
- Bug fixes and features.
190190
- Feature requests.
191191

192+
When contributing, please keep in mind the following:
193+
- Create tests if possible.
194+
- Update the documentation if necessary.
195+
- Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). We use these to automatically generate changelogs.
196+
192197
Unless you explicitly state otherwise, any contribution intentionally submitted
193198
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
194199
dual licensed as above, without any additional terms or conditions.

crates/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ edition = "2018"
1111
categories = ["api-bindings", "command-line-interface"]
1212

1313
[dependencies]
14-
ext-php-rs = { version = ">=0.7.1", path = "../../" }
14+
ext-php-rs = { version = "0.12", path = "../../" }
1515

1616
clap = { version = "4.0", features = ["derive"] }
1717
anyhow = "1"

0 commit comments

Comments
 (0)