Skip to content
Open
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
94 changes: 94 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Create Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g., 1.3.0 or 1.3.0.1)'
required: true
type: string

jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Validate version format
run: |
VERSION="${{ github.event.inputs.version }}"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "Error: Version must be in format X.Y.Z or X.Y.Z.W (e.g., 1.3.0 or 1.3.0.1)"
exit 1
fi
echo "Version format is valid: $VERSION"

- name: Check if tag already exists
run: |
VERSION="${{ github.event.inputs.version }}"
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Error: Tag v$VERSION already exists"
exit 1
fi
echo "Tag v$VERSION does not exist, proceeding..."

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Create Git tag
run: |
VERSION="${{ github.event.inputs.version }}"
git tag -a "v$VERSION" -m "Release version $VERSION"

- name: Push tag
run: |
VERSION="${{ github.event.inputs.version }}"
git push origin "v$VERSION"

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.event.inputs.version }}"

RELEASE_NOTES_FILE=""
if [ -f "RELEASE_NOTES.md" ]; then
RELEASE_NOTES_FILE="RELEASE_NOTES.md"
elif [ -f "release_notes.md" ]; then
RELEASE_NOTES_FILE="release_notes.md"
fi

if [ -n "$RELEASE_NOTES_FILE" ]; then
gh release create "v$VERSION" \
--title "Release v$VERSION" \
--notes-file "$RELEASE_NOTES_FILE" \
--latest
else
gh release create "v$VERSION" \
--title "Release v$VERSION" \
--notes "Release version $VERSION" \
--latest
fi

- name: Delete release notes file if it exists
run: |
VERSION="${{ github.event.inputs.version }}"

if [ -f "RELEASE_NOTES.md" ]; then
git rm RELEASE_NOTES.md
git commit -m "Remove release notes after v$VERSION release"
git push origin master
elif [ -f "release_notes.md" ]; then
git rm release_notes.md
git commit -m "Remove release notes after v$VERSION release"
git push origin master
fi
102 changes: 102 additions & 0 deletions .github/workflows/docker-build-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Docker Build and Push (Branch)

on:
push:
branches-ignore:
- main
- master
workflow_dispatch:
inputs:
branch:
description: 'Branch to build (leave empty for current branch)'
required: false
type: string

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Install goss
run: |
mkdir -p ~/bin
export GOSS_DST=~/bin
curl -fsSL https://goss.rocks/install | sh
echo "$HOME/bin" >> $GITHUB_PATH

- name: Build test image
run: docker build -t lancachenet/monolithic:goss-test .

- name: Run goss tests
run: ./run-tests.sh

build-and-push:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Get branch name
id: branch
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.branch }}" ]]; then
BRANCH="${{ github.event.inputs.branch }}"
git fetch origin "$BRANCH"
git checkout "$BRANCH"
else
BRANCH="${GITHUB_REF#refs/heads/}"
fi
SAFE_BRANCH=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//')
echo "name=${BRANCH}" >> $GITHUB_OUTPUT
echo "safe_name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
echo "Building branch: ${BRANCH} (tag: dev-${SAFE_BRANCH})"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
timeout-minutes: 5
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare image name
id: image
run: |
IMAGE_NAME=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
echo "name=${IMAGE_NAME}" >> $GITHUB_OUTPUT

- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}
tags: |
type=raw,value=dev-${{ steps.branch.outputs.safe_name }}

- name: Build and push Docker image
uses: docker/build-push-action@v7
timeout-minutes: 60
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:cache-amd64
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:cache-amd64,mode=max
provenance: false
80 changes: 80 additions & 0 deletions .github/workflows/docker-build-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Docker Build and Push (Dev)

on:
push:
branches: [ master ]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Install goss
run: |
mkdir -p ~/bin
export GOSS_DST=~/bin
curl -fsSL https://goss.rocks/install | sh
echo "$HOME/bin" >> $GITHUB_PATH

- name: Build test image
run: docker build -t lancachenet/monolithic:goss-test .

- name: Run goss tests
run: ./run-tests.sh

build-and-push:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
timeout-minutes: 5
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare image name
id: image
run: |
IMAGE_NAME=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
echo "name=${IMAGE_NAME}" >> $GITHUB_OUTPUT

- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}
tags: |
type=raw,value=dev

- name: Build and push Docker image
uses: docker/build-push-action@v7
timeout-minutes: 60
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:cache-amd64
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:cache-amd64,mode=max
provenance: false
118 changes: 118 additions & 0 deletions .github/workflows/docker-build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Docker Build and Push (Release)

on:
workflow_run:
workflows: ["Create Release"]
types:
- completed
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
check-trigger:
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.check.outputs.should-run }}
steps:
- name: Check if workflow should run
id: check
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "should-run=true" >> $GITHUB_OUTPUT
echo "Manually triggered"
elif [[ "${{ github.event_name }}" == "workflow_run" && "${{ github.event.workflow_run.conclusion }}" == "success" ]]; then
echo "should-run=true" >> $GITHUB_OUTPUT
echo "Triggered by successful Create Release workflow"
else
echo "should-run=false" >> $GITHUB_OUTPUT
echo "Conditions not met. Event: ${{ github.event_name }}, Conclusion: ${{ github.event.workflow_run.conclusion }}"
fi

test:
needs: check-trigger
if: ${{ needs.check-trigger.outputs.should-run == 'true' }}
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: master

- name: Install goss
run: |
mkdir -p ~/bin
export GOSS_DST=~/bin
curl -fsSL https://goss.rocks/install | sh
echo "$HOME/bin" >> $GITHUB_PATH

- name: Build test image
run: docker build -t lancachenet/monolithic:goss-test .

- name: Run goss tests
run: ./run-tests.sh

build-and-push:
needs: [check-trigger, test]
if: ${{ needs.check-trigger.outputs.should-run == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: master

- name: Get release version
id: version
run: |
VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
timeout-minutes: 5
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare image name
id: image
run: |
IMAGE_NAME=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
echo "name=${IMAGE_NAME}" >> $GITHUB_OUTPUT

- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}
tags: |
type=raw,value=latest
type=raw,value=release
type=raw,value=${{ steps.version.outputs.VERSION }}

- name: Build and push Docker image
uses: docker/build-push-action@v7
timeout-minutes: 60
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:cache-amd64
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ steps.image.outputs.name }}:cache-amd64,mode=max
provenance: false
Loading