From c09089b777750985318ba3ac9569d793dfb1e839 Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Wed, 25 Feb 2026 17:51:15 +0000 Subject: [PATCH 1/2] build(*): Improve build automation --- .github/workflows/docker.yml | 22 ++------- .github/workflows/release.yml | 88 +++++++++++++++++++++++++++++++++++ .releaserc.json | 44 ++++++++++++++++++ README.md | 12 ++--- 4 files changed, 142 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .releaserc.json diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d3aeb35..582377e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,14 +1,9 @@ -name: Docker +name: Docker CI on: pull_request: branches: - main - push: - branches: - - main - tags: - - "v*.*.*" env: IMAGE_NAME: jcreek23/open-network-diagram @@ -26,30 +21,21 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log in to Docker Hub - if: github.event_name == 'push' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: docker.io/${{ env.IMAGE_NAME }} tags: | - type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=pr type=sha,prefix=sha- - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - name: Build (PR) / Build+Push (push) + - name: Build (PR validation only) uses: docker/build-push-action@v6 with: context: . file: Dockerfile - push: ${{ github.event_name == 'push' }} + push: false tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..57189dd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: Release + +on: + push: + branches: + - main + +env: + IMAGE_NAME: jcreek23/open-network-diagram + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + new_release_published: ${{ steps.semantic.outputs.new_release_published }} + new_release_version: ${{ steps.semantic.outputs.new_release_version }} + new_release_major_version: ${{ steps.semantic.outputs.new_release_major_version }} + new_release_minor_version: ${{ steps.semantic.outputs.new_release_minor_version }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Create Git tag + GitHub release + id: semantic + uses: cycjimmy/semantic-release-action@v4 + with: + extra_plugins: | + @semantic-release/commit-analyzer + @semantic-release/release-notes-generator + @semantic-release/github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + docker: + needs: release + if: needs.release.outputs.new_release_published == 'true' + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: docker.io/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest + type=raw,value=${{ needs.release.outputs.new_release_version }} + type=raw,value=${{ needs.release.outputs.new_release_major_version }}.${{ needs.release.outputs.new_release_minor_version }} + type=sha,prefix=sha- + + - name: Build and push release image + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..e76ac67 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,44 @@ +{ + "branches": ["main"], + "tagFormat": "v${version}", + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "type": "build", + "release": "patch" + }, + { + "type": "chore", + "release": "patch" + }, + { + "type": "ci", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "refactor", + "release": "patch" + }, + { + "type": "style", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + } + ] + } + ], + "@semantic-release/release-notes-generator", + "@semantic-release/github" + ] +} diff --git a/README.md b/README.md index cac3cf6..fa36b88 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # **Open Network Diagram** ![Docker Pulls](https://img.shields.io/docker/pulls/jcreek23/open-network-diagram) -![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/jcreek/OpenNetworkDiagram/docker.yml) +![Release Workflow](https://img.shields.io/github/actions/workflow/status/jcreek/OpenNetworkDiagram/release.yml?branch=main&label=release) +![Docker CI Workflow](https://img.shields.io/github/actions/workflow/status/jcreek/OpenNetworkDiagram/docker.yml?label=docker%20ci) +![Latest Release](https://img.shields.io/github/v/release/jcreek/OpenNetworkDiagram?display_name=tag&sort=semver) ![Netlify](https://img.shields.io/netlify/3128f05f-831b-412c-ada0-46bc3d6e61d5) - - **A declarative, self-hosted tool for visualising and managing home lab & network architecture diagrams.** --- @@ -107,7 +107,7 @@ open-network-diagram/ ├── Dockerfile # Docker build/runtime ├── docker-compose.yml # Local Docker run with mounted data ├── netlify.toml # Netlify build config -├── .github/workflows/ # CI workflows (Docker image build/push) +├── .github/workflows/ # CI workflows (PR build + automated release/publish) └── README.md # Documentation ``` @@ -129,8 +129,8 @@ docker run --rm -p 8080:80 -v "$(pwd)/data:/usr/share/nginx/html/data:ro" open-n ### **CI/CD (GitHub Actions + Netlify)** -- GitHub Actions workflow (`.github/workflows/docker.yml`) builds Docker on PRs. -- Pushes to `main` publish Docker images to **Docker Hub** (`jcreek23/open-network-diagram`). +- GitHub Actions workflow (`.github/workflows/docker.yml`) builds Docker on PRs (validation only). +- GitHub Actions workflow (`.github/workflows/release.yml`) runs on `main`, creates semantic version tags/releases, and publishes Docker images to **Docker Hub** (`jcreek23/open-network-diagram`). - Netlify uses its own CI/CD pipeline with `netlify.toml` (`pnpm run build:netlify`). --- From b02cf604a3417a6f6599278a530fece00120841d Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Wed, 25 Feb 2026 18:01:04 +0000 Subject: [PATCH 2/2] fix(*): Address issues identified in PR comments --- .github/workflows/release.yml | 5 ++++- .releaserc.json | 39 ++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57189dd..375c107 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,6 +17,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + issues: write + pull-requests: write outputs: new_release_published: ${{ steps.semantic.outputs.new_release_published }} new_release_version: ${{ steps.semantic.outputs.new_release_version }} @@ -36,10 +38,11 @@ jobs: - name: Create Git tag + GitHub release id: semantic - uses: cycjimmy/semantic-release-action@v4 + uses: cycjimmy/semantic-release-action@v5.0.2 with: extra_plugins: | @semantic-release/commit-analyzer + conventional-changelog-conventionalcommits @semantic-release/release-notes-generator @semantic-release/github env: diff --git a/.releaserc.json b/.releaserc.json index e76ac67..a5ecc43 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -38,7 +38,44 @@ ] } ], - "@semantic-release/release-notes-generator", + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "build", + "section": "Build" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "ci", + "section": "CI" + }, + { + "type": "docs", + "section": "Docs" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "style", + "section": "Style" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], "@semantic-release/github" ] }