Skip to content

Commit d420d6b

Browse files
committed
ci(release): add release bot
Refs: #340
1 parent 64fbb41 commit d420d6b

File tree

6 files changed

+195
-18
lines changed

6 files changed

+195
-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: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,74 @@ 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.3"
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+
- name: Configure Clang
63+
run: |
64+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
65+
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
66+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/bin/llvm-config" >> $GITHUB_ENV
67+
- name: Run rustfmt
68+
run: cargo fmt --all -- --check
69+
- name: Run clippy
70+
run: cargo clippy --all -- -D warnings
71+
# Docs
72+
- name: Run rustdoc
73+
run: cargo rustdoc -- -D warnings
74+
- name: Build with docs stub
75+
env:
76+
DOCS_RS: ""
77+
run: cargo clean && cargo build
1278
build:
1379
name: Build and Test
1480
runs-on: ${{ matrix.os }}
@@ -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
@@ -89,24 +155,9 @@ jobs:
89155
env:
90156
EXT_PHP_RS_TEST: ""
91157
run: cargo build --release --features closure,anyhow --all
92-
# Test & lint
158+
# Test
93159
- name: Test inline examples
94160
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
110161
build-zts:
111162
name: Build with ZTS
112163
runs-on: ubuntu-latest

.github/workflows/release-plz.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
steps:
19+
- name: Generate GitHub token
20+
uses: actions/create-github-app-token@v1
21+
id: generate-token
22+
with:
23+
app-id: ${{ secrets.APP_ID }}
24+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
- name: Install Rust toolchain
30+
uses: dtolnay/rust-toolchain@stable
31+
- name: Run release-plz
32+
uses: release-plz/[email protected]
33+
with:
34+
command: release
35+
env:
36+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
37+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
38+
39+
release-plz-pr:
40+
name: Release-plz PR
41+
runs-on: ubuntu-latest
42+
concurrency:
43+
group: release-plz-${{ github.ref }}
44+
cancel-in-progress: false
45+
steps:
46+
- name: Generate GitHub token
47+
uses: actions/create-github-app-token@v1
48+
id: generate-token
49+
with:
50+
app-id: ${{ secrets.APP_ID }}
51+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
with:
55+
fetch-depth: 0
56+
- name: Install Rust toolchain
57+
uses: dtolnay/rust-toolchain@stable
58+
- name: Run release-plz
59+
uses: release-plz/[email protected]
60+
with:
61+
command: release-pr
62+
env:
63+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
64+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.release-plz.toml

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

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ Contributions welcome include:
181181
- Bug fixes and features.
182182
- Feature requests.
183183

184+
When contributing, please keep in mind the following:
185+
- Create tests if possible.
186+
- Update the documentation if necessary.
187+
- Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). We use these to automatically generate changelogs.
188+
184189
Unless you explicitly state otherwise, any contribution intentionally submitted
185190
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
186191
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)