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
60 changes: 5 additions & 55 deletions .github/workflows/crates-version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,10 @@ jobs:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo tools
uses: actions/cache@v3
id: cache-cargo-tools
with:
path: |
~/.cargo/bin/cargo-workspaces
~/.cargo/bin/git-cliff
key: cargo-tools-${{ runner.os }}-v1
restore-keys: |
cargo-tools-${{ runner.os }}-

- name: Install cargo tools
if: steps.cache-cargo-tools.outputs.cache-hit != 'true'
run: |
cargo install cargo-workspaces
cargo install git-cliff
uses: taiki-e/install-action@v2
with:
tool: cargo-release,git-cliff

- name: Setup Git
run: |
Expand All @@ -59,50 +47,12 @@ jobs:
BRANCH="${GITHUB_REF_NAME}"
PRE_ID="${{ inputs.pre-id }}"
FORCE="${{ inputs.force }}"
REPO_ROOT="$(git rev-parse --show-toplevel)"

echo "Running on branch: $BRANCH"
echo "Prerelease identifier: $PRE_ID"
echo "Force flag: $FORCE"
echo "Will bump version for ALL crates"

FORCE_FLAG=""
if [ "$FORCE" = "true" ]; then
FORCE_FLAG="--force '*'"
fi

CHANGED_CRATES=$(cargo workspaces changed)

if [[ -z "$CHANGED_CRATES" ]]; then
echo "No crates changed since last tag. Nothing to do."
exit 0
fi

case "$BRANCH" in
main)
cargo workspaces version --allow-branch "$BRANCH" --no-global-tag --yes $FORCE_FLAG --no-git-push
;;
development)
cargo workspaces version --allow-branch "$BRANCH" --no-global-tag prerelease --pre-id "$PRE_ID" --yes $FORCE_FLAG --no-git-push
;;
*)
echo "❌ This workflow can only be run on 'main' or 'development'."
exit 1
;;
esac

NEW_TAGS=$(git tag --points-at HEAD)
echo "Tags created locally:"
echo "$NEW_TAGS"

../../scripts/generate-changelogs.sh "$CHANGED_CRATES"

echo "Amending commit to include changelogs..."
git commit --amend --no-edit

for tag in $NEW_TAGS; do
echo "Re-applying tag $tag on amended commit..."
git tag -f "$tag"
done
$REPO_ROOT/scripts/bump-version.sh

git push origin "$BRANCH"
git push origin --tags
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-

- name: Install cargo tools
uses: taiki-e/install-action@v2
with:
tool: cargo-release,git-cliff

- name: Publish quickmark-cli to crates.io
run: cargo publish -p quickmark-cli --token ${{ secrets.CRATES_IO_TOKEN }}

- name: Generate changelog
id: changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --include-path "crates/quickmark-cli/**" --tag-pattern "quickmark-cli@*" --latest
run: |
changelog=$(./scripts/latest-changes.sh quickmark-cli)
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$changelog" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create GitHub release
uses: softprops/action-gh-release@v2
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/release-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,21 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-

- name: Install cargo tools
uses: taiki-e/install-action@v2
with:
tool: cargo-release,git-cliff

- name: Publish quickmark-core to crates.io
run: cargo publish -p quickmark-core --token ${{ secrets.CRATES_IO_TOKEN }}

- name: Generate changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --include-path "crates/quickmark-core/**" --tag-pattern "quickmark-core@*" --latest
id: changelog
run: |
changelog=$(./scripts/latest-changes.sh quickmark-core)
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$changelog" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create GitHub release
uses: softprops/action-gh-release@v2
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/release-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,19 @@ jobs:
cp "$artifact_dir"/*.tar.gz release-archives/ 2>/dev/null || true
fi
done
# Copy changelog
cp artifacts/changelog/CHANGELOG.md ./ 2>/dev/null || echo "No changelog found"
ls -la release-archives/
if [ -f CHANGELOG.md ]; then ls -la CHANGELOG.md; fi

- name: Install cargo tools
uses: taiki-e/install-action@v2
with:
tool: cargo-release,git-cliff

- name: Generate changelog
id: changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --include-path "crates/quickmark-server/**" --tag-pattern "quickmark-server@*" --latest
run: |
changelog=$(./scripts/latest-changes.sh quickmark-server)
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$changelog" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create release
uses: softprops/action-gh-release@v2
Expand Down
1 change: 1 addition & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
filter_unconventional = true
6 changes: 6 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# pre-release-commit-message = "chore: Release {{crate_name}} version {{version}}"
tag-name = "{{crate_name}}@{{version}}"
verify = false
push = false
publish = false
consolidate-commits = true
85 changes: 85 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
set -euo pipefail
# set -x

# Resolve script directory (so paths.sh works regardless of cwd)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT=$(git rev-parse --show-toplevel)

source "${SCRIPT_DIR}/lib.sh"
# Todo: automate?
crates=(quickmark-core quickmark-cli quickmark-server)
changed_crates=()

for crate in "${crates[@]}"; do
echo "Checking version for crate: $crate"
next_ver=$(next_version "$crate")
if [ -n "$next_ver" ]; then
echo "Found changes for $crate, bumping to version: $next_ver"
changed_crates+=("$crate")
if ! cargo release version "$next_ver" -p "$crate" --execute --no-confirm; then
echo "Error: Failed to bump version for crate '$crate'" >&2
exit 1
fi
else
echo "No changes detected for crate: $crate"
fi
done

if [ ${#changed_crates[@]} -eq 0 ]; then
echo "No changes since the last release"
exit 0
fi

echo "Creating release commit..."
if ! cargo release commit --execute --no-confirm; then
echo "Error: Failed to create release commit" >&2
exit 1
fi

echo "Creating release tags..."
if ! cargo release tag --execute --no-confirm; then
echo "Error: Failed to create release tags" >&2
exit 1
fi

NEW_TAGS=$(git tag --points-at HEAD)
echo "Tags created locally:"
echo "$NEW_TAGS"

echo "generating changelogs..."
for crate in "${changed_crates[@]}"; do
CRATE_DIR=$(cargo metadata --format-version 1 --no-deps \
| jq -r --arg NAME "$crate" '.packages[] | select(.name==$NAME) | .manifest_path' \
| xargs dirname)

# Validate that crate directory was found
if [[ -z "$CRATE_DIR" || ! -d "$CRATE_DIR" ]]; then
echo "Error: Could not find directory for crate '$crate'" >&2
exit 1
fi

REL_CRATE_DIR=$(realpath --relative-to="$REPO_ROOT" "$CRATE_DIR")

# Build include paths array
mapfile -t include_args < <(get_crate_include_args "$crate")

echo "Generating changelog for $crate..."
if ! git cliff \
--tag-pattern "$crate@*" \
"${include_args[@]}" \
--output "$REL_CRATE_DIR/CHANGELOG.md"; then
echo "Error: Failed to generate changelog for crate '$crate'" >&2
exit 1
fi

git add "$REL_CRATE_DIR/CHANGELOG.md"
done

echo "Amending commit to include changelogs..."
git commit --amend --no-edit

for tag in $NEW_TAGS; do
echo "Re-applying tag $tag on amended commit..."
git tag -f "$tag"
done
31 changes: 0 additions & 31 deletions scripts/generate-changelogs.sh

This file was deleted.

25 changes: 25 additions & 0 deletions scripts/latest-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
# set -x

# Resolve script directory (so paths.sh works regardless of cwd)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT=$(git rev-parse --show-toplevel)

source "${SCRIPT_DIR}/lib.sh"

if [[ $# -ne 1 ]]; then
echo "Usage: $0 <crate-name>" >&2
exit 1
fi

CRATE="$1"

mapfile -t include_args < <(get_crate_include_args "$CRATE")

changes=`git cliff \
--tag-pattern "$CRATE@*" \
"${include_args[@]}" \
--latest`

echo "$changes"
Loading