Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(release): add release bot #346

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
# Check for updates every Monday
schedule:
interval: "weekly"
88 changes: 70 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,75 @@ on:
branches:
- master
pull_request:
env:
RUST_CACHE_PREFIX: "v0-rust"

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
clang: "17"
php_version: "8.2"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check typos
uses: crate-ci/typos@master
- name: Validate commit messages
run: |
git show-ref
curl -sSfL https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip | zcat > convco
chmod +x convco
./convco check refs/remotes/origin/master..HEAD
rm convco
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
env:
debug: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
components: rustfmt, clippy
toolchain: stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
with:
# increment this manually to force cache eviction
prefix-key: ${{ env.RUST_CACHE_PREFIX }}
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/llvm-${{ env.clang }}
key: ubuntu-latest-llvm-${{ env.clang }}
- name: Setup LLVM & Clang
id: clang
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ env.clang }}
directory: ${{ runner.temp }}/llvm-${{ env.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
run: |
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/bin/llvm-config" >> $GITHUB_ENV
- name: Run rustfmt
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all -- -D warnings
# Docs
- name: Run rustdoc
run: cargo rustdoc -- -D warnings
- name: Build with docs stub
env:
DOCS_RS: ""
run: cargo clean && cargo build
build:
name: Build and Test
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -50,7 +117,6 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- run: rustup show
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
Expand All @@ -59,7 +125,7 @@ jobs:
# if: matrix.rust == 'stable'
with:
# increment this manually to force cache eviction
prefix-key: "v0-rust"
prefix-key: ${{ env.RUST_CACHE_PREFIX }}
# LLVM & Clang
- name: Cache LLVM and Clang
id: cache-llvm
Expand All @@ -77,6 +143,7 @@ jobs:
with:
version: ${{ matrix.clang }}
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
# Macos build doesn't work with clang < 18. As a build for version 18 is not available, we skip the setup
if: "!contains(matrix.os, 'windows') && !contains(matrix.os, 'macos')"
Expand All @@ -89,24 +156,9 @@ jobs:
env:
EXT_PHP_RS_TEST: ""
run: cargo build --release --features closure,anyhow --all
# Test & lint
# Test
- name: Test inline examples
run: cargo test --release --all --features closure,anyhow --no-fail-fast
- name: Run rustfmt
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
run: cargo fmt --all -- --check
- name: Run clippy
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
run: cargo clippy --all -- -D warnings
# Docs
- name: Run rustdoc
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
run: cargo rustdoc -- -D warnings
- name: Build with docs stub
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
env:
DOCS_RS: ""
run: cargo clean && cargo build
build-zts:
name: Build with ZTS
runs-on: ubuntu-latest
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Release-plz

permissions:
pull-requests: write
contents: write

on:
workflow_run:
workflows: ["Build and Lint"]
branches: ["master"]
types:
- completed

jobs:
release-plz-release:
name: Release-plz release
runs-on: ubuntu-latest
env:
clang: '17'
php_version: '8.2'
steps:
- name: Generate GitHub token
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
env:
debug: true
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/llvm-${{ env.clang }}
key: ubuntu-latest-llvm-${{ env.clang }}
- name: Setup LLVM & Clang
id: clang
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ env.clang }}
directory: ${{ runner.temp }}/llvm-${{ env.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
run: |
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/bin/llvm-config" >> $GITHUB_ENV
- name: Run release-plz
uses: release-plz/[email protected]
with:
command: release
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

release-plz-pr:
name: Release-plz PR
runs-on: ubuntu-latest
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Generate GitHub token
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: release-plz/[email protected]
with:
command: release-pr
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
52 changes: 52 additions & 0 deletions .release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[workspace]
release_always = false
publish_all_features = true
git_release_body = """
{{ changelog }}
{% if remote.contributors %}
### Thanks to the contributors for this release:
{% for contributor in remote.contributors %}
* @{{ contributor.username }}
{% endfor %}
{% endif %}
"""

[changelog]
header = "# Changelog"
body = """
{%- macro username(commit) -%}
{% if commit.remote.username %} (by @{{ commit.remote.username }}){% endif -%}
{% endmacro -%}
{% macro commit_message(commit) %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{{ self::username(commit=commit) }} \
{%- if commit.links %} \
{% for link in commit.links | unique(attribute="href") %}\
[[{{link.text}}]({{link.href}})] \
{% endfor %}\
{% endif %}
{%- if commit.breaking and commit.breaking_description and not commit.breaking_description == commit.message%}
> {{ commit.breaking_description -}}
{% endif -%}
{% endmacro %}
## [{{ version | trim_start_matches(pat="v") }}]{%- if release_link -%}({{ release_link }}){% endif %} - {{ timestamp | date(format="%Y-%m-%d") -}}
{%- for group, commits in commits | group_by(attribute="group") %}

### {{ group | upper_first -}}
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") -%}
{{- self::commit_message(commit=commit) -}}
{% endfor -%}
{%- for commit in commits -%}
{% if not commit.scope -%}
{{- self::commit_message(commit=commit) -}}
{% endif -%}
{% endfor -%}
{% endfor %}
"""
link_parsers = [
{ pattern = "#(\\d+)", href = "https://github.com/davidcole1340/ext-php-rs/issues/$1" },
]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ Contributions welcome include:
- Bug fixes and features.
- Feature requests.

When contributing, please keep in mind the following:
- Create tests if possible.
- Update the documentation if necessary.
- Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). We use these to automatically generate changelogs.

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
categories = ["api-bindings", "command-line-interface"]

[dependencies]
ext-php-rs = { version = ">=0.7.1", path = "../../" }
ext-php-rs = { version = "0.12.0", path = "../../" }

clap = { version = "4.0", features = ["derive"] }
anyhow = "1"
Expand Down
Loading