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
139 changes: 44 additions & 95 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,112 +1,61 @@
name: CI

on:
push:
branches: [main]
tags: ['v*']
branches:
- main
tags:
- v*
pull_request:
branches: [main]

branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: luxfi/operator

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo check --release

docker:
needs: check
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract version from tag
id: version
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "version=latest" >> "$GITHUB_OUTPUT"
fi

- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=

- uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo check --release
release:
needs: [check, docker]
needs: check
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate release notes
id: notes
run: |
TAG="${GITHUB_REF#refs/tags/}"
PREV_TAG=$(git tag --sort=-creatordate | grep -v "^${TAG}$" | head -1 || echo "")
if [ -n "$PREV_TAG" ]; then
RANGE="${PREV_TAG}..${TAG}"
else
RANGE="${TAG}"
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
{
echo "notes<<EOF"
echo "## Docker Image"
echo ""
echo "\`\`\`"
echo "docker pull ghcr.io/luxfi/operator:${TAG#v}"
echo "\`\`\`"
echo ""
echo "## Changes"
echo ""
git log --pretty=format:"- %s (%h)" ${RANGE} 2>/dev/null || echo "- Initial release"
echo ""
echo "EOF"
} >> "$GITHUB_OUTPUT"

- uses: softprops/action-gh-release@v2
with:
name: ${{ steps.notes.outputs.tag }}
body: ${{ steps.notes.outputs.notes }}
generate_release_notes: false
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate release notes
id: notes
run: |
TAG="${GITHUB_REF#refs/tags/}"
PREV_TAG=$(git tag --sort=-creatordate | grep -v "^${TAG}$" | head -1 || echo "")
if [ -n "$PREV_TAG" ]; then
RANGE="${PREV_TAG}..${TAG}"
else
RANGE="${TAG}"
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
{
echo "notes<<EOF"
echo "## Docker Image"
echo ""
echo "\`\`\`"
echo "docker pull ghcr.io/luxfi/operator:${TAG#v}"
echo "\`\`\`"
echo ""
echo "## Changes"
echo ""
git log --pretty=format:"- %s (%h)" ${RANGE} 2>/dev/null || echo "- Initial release"
echo ""
echo "EOF"
} >> "$GITHUB_OUTPUT"
- uses: softprops/action-gh-release@v2
with:
name: ${{ steps.notes.outputs.tag }}
body: ${{ steps.notes.outputs.notes }}
generate_release_notes: false
9 changes: 9 additions & 0 deletions .github/workflows/workflow-sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Workflow Sanity
on:
pull_request:
push:
branches: [main]

jobs:
sanity:
uses: hanzoai/.github/.github/workflows/workflow-sanity.yml@main
Loading