Skip to content

Commit

Permalink
ci(release): add release bot
Browse files Browse the repository at this point in the history
Refs: #340
  • Loading branch information
Xenira committed Dec 2, 2024
1 parent 64fbb41 commit 04110fe
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 9 deletions.
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"
68 changes: 60 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,66 @@ on:
branches:
- master
pull_request:
env:
RUST_CACHE_PREFIX: "v0-rust"

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
clang: "17"
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: '8.2'
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 }}
- 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
build:
name: Build and Test
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -59,7 +117,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 Down Expand Up @@ -89,15 +147,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'
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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
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
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 }}
50 changes: 50 additions & 0 deletions .release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[workspace]
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 @@ -181,6 +181,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

0 comments on commit 04110fe

Please sign in to comment.