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
21 changes: 2 additions & 19 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
paths-ignore:
- .github/**

jobs:
build:
Expand All @@ -25,19 +24,3 @@ jobs:
run: cargo test
- name: Check artifact weight
run: ls -lh target/release/

publish:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --no-verify
113 changes: 113 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Publish to crates.io

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
override: true

- name: Get version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT

- name: Verify version matches tag
run: |
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
TAG_VERSION=${{ steps.get_version.outputs.version }}
echo "Cargo.toml version: $CARGO_VERSION"
echo "Git tag version: $TAG_VERSION"
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "❌ Version mismatch: Cargo.toml has $CARGO_VERSION but tag is $TAG_VERSION"
exit 1
fi
echo "✅ Version matches tag"

- name: Generate changelog for release
id: changelog
run: |
# Extract the changelog section for this version
if [ -f "CHANGELOG.md" ]; then
# Use awk to extract the section between the current version and the next version
CHANGELOG_SECTION=$(awk "/^## \[${{ steps.get_version.outputs.version }}\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md)

# If no section found, generate from git commits
if [ -z "$CHANGELOG_SECTION" ]; then
echo "No changelog section found for version ${{ steps.get_version.outputs.version }}"
echo "Generating changelog from git commits..."

# Get the previous tag
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")

if [ -n "$PREVIOUS_TAG" ]; then
echo "### Changes since $PREVIOUS_TAG" > temp_changelog.md
echo "" >> temp_changelog.md
git log --oneline --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD >> temp_changelog.md
else
echo "### Changes in this release" > temp_changelog.md
echo "" >> temp_changelog.md
git log --oneline --pretty=format:"- %s (%h)" -n 10 >> temp_changelog.md
fi

CHANGELOG_SECTION=$(cat temp_changelog.md)
rm temp_changelog.md
fi
else
echo "No CHANGELOG.md found, generating from git commits..."

# Get the previous tag
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")

if [ -n "$PREVIOUS_TAG" ]; then
echo "### Changes since $PREVIOUS_TAG" > temp_changelog.md
echo "" >> temp_changelog.md
git log --oneline --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD >> temp_changelog.md
else
echo "### Changes in this release" > temp_changelog.md
echo "" >> temp_changelog.md
git log --oneline --pretty=format:"- %s (%h)" -n 10 >> temp_changelog.md
fi

CHANGELOG_SECTION=$(cat temp_changelog.md)
rm temp_changelog.md
fi

# Write to file for release update
echo "$CHANGELOG_SECTION" > release_notes.md
echo "Generated changelog for release page"

- name: Update release with changelog
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.tag }}
body_path: release_notes.md
append_body: true

- name: Run tests
run: cargo test

- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
echo "📦 Publishing to crates.io..."
cargo publish --no-verify
echo "✅ Successfully published to crates.io"
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "yabe-gitops"
description = "GitOps organizer"
repository = "https://github.com/dvrkn/yabe"
readme = "README.md"
version = "0.1.8"
version = "0.1.9"
edition = "2021"
keywords = ["gitops", "kubernetes", "argocd", "yaml", "helm"]
license = "MIT"
Expand Down