Skip to content

Commit 56c733b

Browse files
committed
ci(release): add release bot
Refs: #340
1 parent a493b8b commit 56c733b

File tree

6 files changed

+226
-19
lines changed

6 files changed

+226
-19
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 & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,75 @@ on:
77
branches:
88
- master
99
pull_request:
10+
env:
11+
RUST_CACHE_PREFIX: "v0-rust"
1012

1113
jobs:
14+
lint:
15+
name: Lint
16+
runs-on: ubuntu-latest
17+
env:
18+
clang: "17"
19+
php_version: "8.2"
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Check typos
26+
uses: crate-ci/typos@master
27+
- name: Validate commit messages
28+
run: |
29+
git show-ref
30+
curl -sSfL https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip | zcat > convco
31+
chmod +x convco
32+
./convco check refs/remotes/origin/master..HEAD
33+
rm convco
34+
- name: Setup PHP
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: ${{ env.php_version }}
38+
env:
39+
debug: true
40+
- name: Setup Rust
41+
uses: dtolnay/rust-toolchain@master
42+
with:
43+
components: rustfmt, clippy
44+
toolchain: stable
45+
- name: Cache cargo dependencies
46+
uses: Swatinem/rust-cache@v2
47+
with:
48+
# increment this manually to force cache eviction
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 }}
@@ -50,7 +117,6 @@ jobs:
50117
uses: dtolnay/rust-toolchain@master
51118
with:
52119
toolchain: ${{ matrix.rust }}
53-
components: rustfmt, clippy
54120
- run: rustup show
55121
- name: Cache cargo dependencies
56122
uses: Swatinem/rust-cache@v2
@@ -59,7 +125,7 @@ jobs:
59125
# if: matrix.rust == 'stable'
60126
with:
61127
# increment this manually to force cache eviction
62-
prefix-key: "v0-rust"
128+
prefix-key: ${{ env.RUST_CACHE_PREFIX }}
63129
# LLVM & Clang
64130
- name: Cache LLVM and Clang
65131
id: cache-llvm
@@ -77,6 +143,7 @@ jobs:
77143
with:
78144
version: ${{ matrix.clang }}
79145
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
146+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
80147
- name: Configure Clang
81148
# Macos build doesn't work with clang < 18. As a build for version 18 is not available, we skip the setup
82149
if: "!contains(matrix.os, 'windows') && !contains(matrix.os, 'macos')"
@@ -89,24 +156,9 @@ jobs:
89156
env:
90157
EXT_PHP_RS_TEST: ""
91158
run: cargo build --release --features closure,anyhow --all
92-
# Test & lint
159+
# Test
93160
- name: Test inline examples
94161
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
110162
build-zts:
111163
name: Build with ZTS
112164
runs-on: ubuntu-latest

.github/workflows/release-plz.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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: Generate GitHub token
23+
uses: actions/create-github-app-token@v1
24+
id: generate-token
25+
with:
26+
app-id: ${{ secrets.APP_ID }}
27+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ env.php_version }}
36+
env:
37+
debug: true
38+
- name: Install Rust toolchain
39+
uses: dtolnay/rust-toolchain@stable
40+
- name: Cache LLVM and Clang
41+
id: cache-llvm
42+
uses: actions/cache@v3
43+
with:
44+
path: ${{ runner.temp }}/llvm-${{ env.clang }}
45+
key: ubuntu-latest-llvm-${{ env.clang }}
46+
- name: Setup LLVM & Clang
47+
id: clang
48+
uses: KyleMayes/install-llvm-action@v2
49+
with:
50+
version: ${{ env.clang }}
51+
directory: ${{ runner.temp }}/llvm-${{ env.clang }}
52+
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
53+
- name: Configure Clang
54+
run: |
55+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
56+
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
57+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/bin/llvm-config" >> $GITHUB_ENV
58+
- name: Run release-plz
59+
uses: release-plz/[email protected]
60+
with:
61+
command: release
62+
env:
63+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
64+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
65+
66+
release-plz-pr:
67+
name: Release-plz PR
68+
runs-on: ubuntu-latest
69+
concurrency:
70+
group: release-plz-${{ github.ref }}
71+
cancel-in-progress: false
72+
steps:
73+
- name: Generate GitHub token
74+
uses: actions/create-github-app-token@v1
75+
id: generate-token
76+
with:
77+
app-id: ${{ secrets.APP_ID }}
78+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
79+
- name: Checkout repository
80+
uses: actions/checkout@v4
81+
with:
82+
fetch-depth: 0
83+
- name: Install Rust toolchain
84+
uses: dtolnay/rust-toolchain@stable
85+
- name: Run release-plz
86+
uses: release-plz/[email protected]
87+
with:
88+
command: release-pr
89+
env:
90+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
91+
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
@@ -185,6 +185,11 @@ Contributions welcome include:
185185
- Bug fixes and features.
186186
- Feature requests.
187187

188+
When contributing, please keep in mind the following:
189+
- Create tests if possible.
190+
- Update the documentation if necessary.
191+
- Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). We use these to automatically generate changelogs.
192+
188193
Unless you explicitly state otherwise, any contribution intentionally submitted
189194
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
190195
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.0", path = "../../" }
1515

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

0 commit comments

Comments
 (0)