Skip to content
Merged
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
47 changes: 47 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
categories:
- title: "⚠️ Breaks"
labels:
- "changelog/break"
- title: "🚧 Deprecation"
labels:
- "changelog/deprecation"
- title: "✨ Features"
labels:
- "changelog/feature"
- title: "🚀 Performance"
labels:
- "changelog/performance"
- title: "🐛 Bug Fixes"
collapse-after: 8
labels:
- "changelog/fix"
- title: "📖 Documentation"
labels:
- "changelog/docs"
collapse-after: 3
- title: "🧰 Maintenance"
labels:
- "changelog/chore"
collapse-after: 3

version-resolver:
major:
labels:
# We must explicitly label a PR with "major" to trigger a major version bump.
- "major"
minor:
labels:
# Any features or breaks will trigger a minor version bump (while we are 0.x)
- "changelog/feature"
- "changelog/break"
default: patch

exclude-labels:
- "changelog/skip"

template: |
## Changes

$CHANGES
76 changes: 76 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: PR Labels

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
pull_request:
# Trigger on these PR activities
types: [opened, reopened, synchronize, labeled, unlabeled]

jobs:
check_changelog_label:
name: Validate Changelog Label
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pull-requests: read # Grant permission to read PR information
steps:
- name: Get PR Labels from API
id: get_labels_api
uses: octokit/request-action@b91aabaa861c777dcdb14e2387e30eddf04619ae # v3.0.0 # Use an action to make API requests
with:
route: GET /repos/{owner}/{repo}/issues/{pull_number}/labels
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided token

- name: Extract and Check Labels
env:
API_RESPONSE: ${{ steps.get_labels_api.outputs.data }}
run: |
REQUIRED_LABELS=(
"changelog/break"
"changelog/deprecation"
"changelog/feature"
"changelog/performance"
"changelog/fix"
"changelog/docs"
"changelog/chore"
"changelog/skip"
)
REQUIRED_LABELS_JSON=$(jq -n '$ARGS.positional' --args "${REQUIRED_LABELS[@]}")
echo "Required Labels: $REQUIRED_LABELS_JSON"

# Parse the response from the API call
# The API returns an array of label objects, we need just the 'name' property
echo "API Response: $API_RESPONSE"

# Extract only the label names into a JSON array
CURRENT_PR_LABELS_JSON=$(echo "$API_RESPONSE" | jq '[.[] | .name]')
echo "Current PR Labels from API: $CURRENT_PR_LABELS_JSON"

# Count how many changelog labels are present
found_labels=()
for label in "${REQUIRED_LABELS[@]}"; do
if echo "$CURRENT_PR_LABELS_JSON" | jq -e --arg label "$label" 'contains([$label])' > /dev/null; then
echo "Found changelog label: $label"
found_labels+=("$label")
fi
done

label_count=${#found_labels[@]}
echo "Total changelog labels found: $label_count"

if [ "$label_count" -eq 0 ]; then
echo "::error file=.github/workflows/labels.yml::Pull Request is missing a required changelog label. Please add exactly one of: ${REQUIRED_LABELS[*]}."
exit 1
elif [ "$label_count" -gt 1 ]; then
echo "::error file=.github/workflows/labels.yml::Pull Request has multiple changelog labels (${found_labels[*]}). Please keep only one."
exit 1
else
echo "Pull Request has exactly one changelog label: ${found_labels[0]}"
fi
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish

concurrency:
group: publish
cancel-in-progress: true

on:
release:
types: [published]

permissions:
contents: read

jobs:
publish-rust:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- uses: ./.github/actions/setup-rust
- name: Install cargo-edit
uses: taiki-e/cache-cargo-install-action@66c9585ef5ca780ee69399975a5e911f47905995
with:
tool: cargo-edit@0.13.10

- name: Cargo Set Version
run: |
# Release Drafter tags are prefixed with "v" (e.g. v0.0.5); cargo
# wants a bare semver, so strip the leading "v".
VERSION="${{ github.event.release.tag_name }}"
cargo set-version "${VERSION#v}"

- name: Publish to crates.io
run: |
cargo publish --no-verify --allow-dirty
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
36 changes: 36 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release Drafter

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
push:
branches:
- develop
workflow_dispatch:
# Permits a custom run to create a pre-release
inputs:
prerelease-identifier:
description: "RC identifier (e.g., rc, beta, alpha)"
type: string
default: "rc"

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: release-drafter/release-drafter@693d20e7c1ce1a81d3a41962f85914253b518449 # v7.3.1
with:
commitish: ${{ github.ref_name }}
prerelease: ${{ github.event_name == 'workflow_dispatch' }}
prerelease-identifier: ${{ inputs.prerelease-identifier || '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 0 additions & 27 deletions .github/workflows/release-plz.yml

This file was deleted.

Loading