Skip to content

Commit 04110fe

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

File tree

6 files changed

+187
-9
lines changed

6 files changed

+187
-9
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: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,66 @@ 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+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Check typos
25+
uses: crate-ci/typos@master
26+
- name: Validate commit messages
27+
run: |
28+
git show-ref
29+
curl -sSfL https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip | zcat > convco
30+
chmod +x convco
31+
./convco check refs/remotes/origin/master..HEAD
32+
rm convco
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: '8.2'
37+
env:
38+
debug: true
39+
- name: Setup Rust
40+
uses: dtolnay/rust-toolchain@master
41+
with:
42+
components: rustfmt, clippy
43+
toolchain: stable
44+
- name: Cache cargo dependencies
45+
uses: Swatinem/rust-cache@v2
46+
with:
47+
# increment this manually to force cache eviction
48+
prefix-key: ${{ env.RUST_CACHE_PREFIX }}
49+
- name: Cache LLVM and Clang
50+
id: cache-llvm
51+
uses: actions/cache@v3
52+
with:
53+
path: ${{ runner.temp }}/llvm-{{ env.clang }}
54+
key: ubuntu-latest-llvm-${{ env.clang }}
55+
- name: Setup LLVM & Clang
56+
id: clang
57+
uses: KyleMayes/install-llvm-action@v2
58+
with:
59+
version: ${{ env.clang }}
60+
directory: ${{ runner.temp }}/llvm-${{ env.clang }}
61+
- name: Configure Clang
62+
run: |
63+
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
64+
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
65+
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/bin/llvm-config" >> $GITHUB_ENV
66+
- name: Run rustfmt
67+
run: cargo fmt --all -- --check
68+
- name: Run clippy
69+
run: cargo clippy --all -- -D warnings
1270
build:
1371
name: Build and Test
1472
runs-on: ${{ matrix.os }}
@@ -59,7 +117,7 @@ jobs:
59117
# if: matrix.rust == 'stable'
60118
with:
61119
# increment this manually to force cache eviction
62-
prefix-key: "v0-rust"
120+
prefix-key: ${{ env.RUST_CACHE_PREFIX }}
63121
# LLVM & Clang
64122
- name: Cache LLVM and Clang
65123
id: cache-llvm
@@ -89,15 +147,9 @@ jobs:
89147
env:
90148
EXT_PHP_RS_TEST: ""
91149
run: cargo build --release --features closure,anyhow --all
92-
# Test & lint
150+
# Test
93151
- name: Test inline examples
94152
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
101153
# Docs
102154
- name: Run rustdoc
103155
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'

.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)