Skip to content

fixed anyml dep

fixed anyml dep #89

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
jobs:
preflight:
name: Preflight Checks
runs-on: blacksmith-2vcpu-ubuntu-2404
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Check for external path dependencies
run: |
if grep -v '^\s*#' Cargo.toml | grep -qE 'path\s*=\s*"\.\.'; then
echo "::error::Cargo.toml contains external path dependencies. Switch them to git/registry deps before releasing."
exit 1
fi
- name: Check Cargo.toml version matches tag
run: |
TAG="${{ github.ref_name }}"
CARGO_VERSION="v$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')"
if [ "$CARGO_VERSION" != "$TAG" ]; then
echo "::error::Cargo.toml version ($CARGO_VERSION) does not match tag ($TAG). Update the version in Cargo.toml before releasing."
exit 1
fi
- name: Check CHANGELOG.md has entry for this version
run: |
TAG="${{ github.ref_name }}"
if ! grep -q "^# $TAG" CHANGELOG.md; then
echo "::error::No changelog entry found for $TAG in CHANGELOG.md. Add a '# $TAG' section before releasing."
exit 1
fi
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install notitia CLI
run: cargo install --git https://github.com/astrum-chat/notitia notitia_cli
- name: Check migrations and create schema snapshot PR if needed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Validates migrations and creates a snapshot if the schema has changed
$CARGO_HOME/bin/notitia snapshot --crate schema
# Check if any new snapshot files were created
SNAPSHOT_FILES=$(git ls-files --others --exclude-standard schema_snapshots/)
if [ -z "$SNAPSHOT_FILES" ]; then
echo "No new schema snapshot files detected. Skipping."
exit 0
fi
echo "New snapshot files detected:"
echo "$SNAPSHOT_FILES"
TAG="${{ github.ref_name }}"
BRANCH="schema-snapshot/${TAG}"
# Skip if branch already exists from a previous run
if git ls-remote --heads origin "${BRANCH}" | grep -q "${BRANCH}"; then
echo "Branch ${BRANCH} already exists. Snapshot PR was likely already created."
exit 0
fi
# Save snapshot files before switching branches
TEMP_DIR=$(mktemp -d)
cp -r schema_snapshots/ "$TEMP_DIR/"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Create branch from main (not the tag)
git fetch origin main
git checkout -b "${BRANCH}" origin/main
# Restore snapshot files onto the main-based branch
cp -r "$TEMP_DIR/schema_snapshots/"* schema_snapshots/
git add schema_snapshots/
git commit -m "Add schema snapshot for ${TAG}"
git push origin "${BRANCH}"
gh pr create \
--base main \
--head "${BRANCH}" \
--title "Schema snapshot for ${TAG}" \
--body "Automated schema snapshot created during the ${TAG} release.
This PR adds the database schema snapshot generated by \`notitia snapshot\` for version ${TAG}.
Created automatically by the release workflow."
echo "::notice::Schema snapshot PR created for ${TAG}."
create-release:
name: Create Release
needs: preflight
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view "${{ github.ref_name }}" > /dev/null 2>&1; then
echo "Release ${{ github.ref_name }} already exists. Skipping creation."
else
TAG="${{ github.ref_name }}"
# Extract changelog section for this version
CHANGELOG=$(awk -v tag="$TAG" '
BEGIN { found=0 }
/^# / {
if (found) exit
if ($0 == "# " tag) { found=1; next }
}
found { print }
' CHANGELOG.md | sed '/./,$!d' | sed -e :a -e '/^\n*$/{$d;N;ba}')
# Error if version not found in changelog
if [ -z "$CHANGELOG" ]; then
echo "::error::No changelog entry found for $TAG in CHANGELOG.md"
exit 1
fi
# Increase heading levels by 1 (# -> ##, ## -> ###)
CHANGELOG=$(printf '%s' "$CHANGELOG" | sed 's/^#/##/')
# Build release body from template
BODY=$(sed "s/VERSION/$TAG/g" .github/RELEASE_TEMPLATE.md)
# Replace the "-" placeholder with changelog content
printf '%s\n' "$CHANGELOG" > /tmp/changelog_section.md
BODY=$(printf '%s\n' "$BODY" | sed '/^-$/{
r /tmp/changelog_section.md
d
}')
# Create draft release
printf '%s\n' "$BODY" > /tmp/release_body.md
gh release create "$TAG" --draft --verify-tag --title "$TAG" --notes-file /tmp/release_body.md
fi
build-macos:
needs: create-release
uses: ./.github/workflows/build-macos.yml
permissions:
contents: write
build-linux:
needs: create-release
uses: ./.github/workflows/build-linux.yml
permissions:
contents: write
build-windows:
needs: create-release
uses: ./.github/workflows/build-windows.yml
permissions:
contents: write
publish-release:
name: Publish Release
needs: [build-macos, build-linux, build-windows]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Publish Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release edit "${{ github.ref_name }}" --draft=false --repo ${{ github.repository }}